4 ms·
Peter also has some great off-heap libraries. It is relatively easy to bypass GC completely.
by jkot 12y ago
Peter also has some great off-heap libraries. It is relatively easy to bypass GC completely.
- Alupis 12y agoHere's Peter's HugeCollections repo[1]. I expected to see some native code being called via JNI, but it's all done in Java. [1] https://github.com/peter-lawrey/HugeCollections https://github.com/peter-lawrey/HugeCollections
- spearo77 12y agoLooks like this is the repo with more recent activity .. https://github.com/OpenHFT/HugeCollections https://github.com/OpenHFT/HugeCollections
- aardvark179 12y agoWell, the native code is replaced by the use of sun.misc.Unsafe to do the off heap allocation and access (look in io & storage classes in https://github.com/OpenHFT/Java-Lang/tree/master/lang/src/main/java/net/openhft/lang/io https://github.com/OpenHFT/Java-Lang/tree/master/lang/src/ma... ). I wonder what this sort of library will look like when Panama is done, assuming it provides the sort of structured off heap storage support I'm hoping for.
- jinmingjian 12y agoIn fact, "to bypass GC completely" is impossible because you still need on-heap objects to access the off-heap stuffs. Note, there is always "no magic".
- chii 12y agobut the on-heap references you keep are only going to be much smaller and thus, alleviate a lot of gc. Offheap storage tend to be things like caching, and caching in java does incur gc costs that you avoid with off-heap stores. It's not a bad solution.
- jkot 12y agoIt is possible to program in java without allocating GC at all. (if you do not count class loader and some other system stuff). Use Unsafe and primitive (on stack) variables. Peter has some nice demos on his blog.