News for hackers. Stuff that matters.
Re:Designing a new concurrent data structure by jerrinot on Monday August 28, 2023 @06:50PM (#37301397)
I could use DirectByteBuffer instances as CHM values. But Java deallocates the backing memory of DirectByteBuffers during object finalization. If there is no on-heap memory pressure then there is no GC and thus no finalization. So it would leak offheap memory. I could also use Unsafe to hack into DirectByteBuffer and call the Cleaner explicitly. Many libraries do that anyway. But then I would still need some kind of reference counting to make sure I won't deallocate a buffer with active readers.
Re:Designing a new concurrent data structure by riku_iki on Monday August 28, 2023 @07:05PM (#37301497)
is there any regret from choosing Java for Db development and need to work around this and likely many other issues?
Re:Designing a new concurrent data structure by cafxx on Tuesday August 29, 2023 @03:18PM (#37312528)
Or you could simply invoke a GC periodically (or every N times a key is removed from the map, or similar schemes).

Another simple way, if we don't like the idea of triggering GCs manually,is to allocate the same buffer both off-heap and on-heap: use the off-heap one for actual key storage, and the on-heap one just to generate heap memory pressure.