DZone interviewed Terracotta CEO Amit Pandey about his company's solution to the GC problem in Java. BigMemory is a snap-in module that provides off-heap memory storage. It is a pure Java solution that works with all JVMs and bypasses the Java garbage collector. You don't even need to be in distributed caching mode to use BigMemory, but it works with both standalone and distributed caches. Like most Ehcache features, it requires only a few lines of configuration. BigMemory can also handle hundreds of millions of objects.
Here are the two steps needed to implement BigMemory (when it is released) in Ehcache:
1. Update the Java classpath and startup arguments to include the new
ehcache-2.3 jar and allocate sufficient memory for the BigMemory off-heap
2. Update the cache configuration in ehcache.xml to set the size of the
BigMemory off-heap store.
<cache name="mycache" maxElementsInMemory="10000"
"People have been trying to make better garbage collectors for years and years. Sun/Oracle have been putting a lot of money into solving this problem, but they're only getting incremental improvements." Terracotta, Pandey says, is able to solve the problem more elegantly because they they "own the cache." So they decided to write their own memory manager and bypass Java GC completely, freeing developers from difficult and time consuming GC tuning.
Currently in the late beta stages, Pandey told DZone that the responses to BigMemory were very positive from early beta users. Testing of the memory manager revealed that the responses to increased memory were fast and flat, meaning that it could be counted on to meet performance requirements in a Service Level Agreement. The greater memory utilization with BigMemory also allows server consolidation.
App Latency Over Time
Terracotta has tested heap sizes up to 350GB without running into a wall like the 2GB threshold in Java GC. Pandey says Terracotta is avoiding many of the problems (fragmentation, poor memory management techniques, etc.) that others have encountered when they tried to build their own memory manager. Pandey says the tagline for BigMemory will be: "Use all the memory you need to get blazingly fast performance."
BigMemory will be available for Ehcache and Hibernate users in October of this year.