When I do new byte[N], I get OutOfMemoryError, despite that the VM claims to have more than enough free space (according to MemoryMXBean, Runtime.freeMemory, visualvm, etc).

My working assumption is that while I have enough free memory, I don't have enough contiguous free memory. Is there a solution to this? Will I get better results from any of:

* ByteBuffer.allocateDirect() - presumably yes, but has other issues relating to overall memory usage on the system * G1GC (or other GC which allocates (relocatable?) regions) - this is a deep hole I haven't yet explored. * Calling System.gc() before allocating a contiguous region [apparently doesn't help].
* Other?

If we do follow a strategy using allocateDirect, will we end up with the same fragmentation issue in the native heap, along with committed off-heap memory which we can no longer effectively use, or is the off-heap memory managed in some manner which avoids this problem?

Thank you.

S.

--
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mechanical-sympathy+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/mechanical-sympathy/6afc5470-adfa-d29d-36af-22c8c8ba52c2%40anarres.org.

Reply via email to