Chapter 3. Elastic Memory (Enterprise Edition Only)

By default, Hazelcast stores your distributed data (map entries, queue items) into Java heap which is subject to garbage collection. As your heap gets bigger, garbage collection might cause your application to pause tens of seconds, badly effecting your application performance and response times. Elastic Memory is Hazelcast with off-heap (direct) memory storage to avoid GC pauses. Even if you have terabytes of cache in-memory with lots of updates, GC will have almost no effect; resulting in more predictable latency and throughput.

Here are the steps to enable Elastic Memory:

  • Set the maximum direct memory JVM can allocate. Example java -XX:MaxDirectMemorySize=60G ...

  • Enable Elastic Memory by setting hazelcast.elastic.memory.enabled Hazelcast Config Property to true.

  • Set the total direct memory size for HazelcastInstance by setting hazelcast.elastic.memory.total.size Hazelcast Config Property. Size can be in MB or GB and abbreviation can be used, such as 60G and 500M.

  • Set the chunk size in KB by setting hazelcast.elastic.memory.chunk.size Hazelcast Config Property. Hazelcast will partition the entire offheap memory into chunks. Default chunk size is 1. Chunk size has to be power of 2 such as 1, 2, 4 and 8.

  • Configure maps you want them to use Elastic Memory by setting StorageType toOFFHEAP. Default value isHEAP.

    Using XML configuration:

    <hazelcast>
        ...
        <map name="default">
            ...
            <storage-type>OFFHEAP</storage-type>
        </map>
    </hazelcast>

    Using Config API:

    MapConfig mapConfig = new MapConfig();
    mapConfig.setStorageType(StorageType.OFFHEAP);

If NearCache is defined for a map, all near cached items are also going to be stored on the same off-heap. So off-heap storage is used for both near cache and distributed object storage.

Also see how to configure license key.