Friday, December 16, 2011

How does BigMemory hide objects from the Java garbage collector?

BigMemory achieves off-heap storage using Direct ByteBuffers, which is a feature introduced with NIO in Java 1.4 to allow zero copy buffers between Java applications and the operating system as it's not possible with memory belonging to Java heap because of unstable location.

An interesting additional property of Direct ByteBuffers is that they give access to memory that won't be managed by the Garbage Collector, hence avoiding its overhead.

Note: The point of BigMemory is not that native memory is faster, but rather, it's to reduce the overhead of the garbage collector having to go through the effort of tracking down references to memory and cleaning it up.

http://www.quora.com/How-does-BigMemory-hide-objects-from-the-Java-garbage-collector


Terracotta's BigMemory takes advantage of non-garbage-collected, off-heap "native memory," and apparently this is about 10x slower than heap-storage due to serialization/deserialization issues.

http://stackoverflow.com/questions/5863316/is-java-native-memory-faster-than-the-heap

Java VM option to setup Direct Memory Size: -XX:MaxDirectMemorySize

No comments: