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.
java -XX:MaxDirectMemorySize=60G ...
Enable Elastic Memory by setting
Hazelcast Config Property
Set the total direct memory size for HazelcastInstance by setting
Hazelcast Config Property. Size can be
in MB or GB and abbreviation can be used, such as
Set the chunk size in KB by setting
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
Default value is
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);
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
Also see how to configure license key.