Hi Talip,
We tried reproducing the issue with a simple testcode, which performs put, get and remove values in MultiMap in a two node cluster on server as shown
HazelcastInstance theirHazelcast = Hazelcast.newHazelcastInstance(config);
MultiMap<String, String> map = Hazelcast.getMultiMap("default");
Runtime rt = Runtime.getRuntime().getRuntime();
while (true) {
int cnt = 0;
while(cnt < 10000)
{
int key = (int) (Math.random() * 10000);
int operation = ((int) (Math.random() * 100));
if (operation < 40) {
map.get(String.valueOf(key));
gets.incrementAndGet();
} else if (operation < 80) {
map.put(String.valueOf(key), "localhost");
puts.incrementAndGet();
} else {
map.remove(String.valueOf(key));
// map.remove(null);
removes.incrementAndGet();
}
cnt++;
}
int putCount = puts.getAndSet(0);
int getCount = gets.getAndSet(0);
int removeCount = removes.getAndSet(0);
System.out.println("TOTAL:" + (removeCount + putCount + getCount) / STATS_SECONDS);
System.out.println("PUTS:" + putCount / STATS_SECONDS);
System.out.println("GEtS:" + getCount / STATS_SECONDS);
System.out.println("REMOVES:" + removeCount / STATS_SECONDS);
System.out.println("Total in KB " + rt.totalMemory()/1024 + " used: " + (rt.totalMemory() - rt.freeMemory()) /1024);
try {
Thread.sleep(STATS_SECONDS * 1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The test was running from last 24 hours, but heap is normal, no memory leak happening.
Even on customer site, it happens once in a month.
Here are my finding from the heap dumps of three scenerios (MemoryLeak in customer site, Normal Customer site and heap dump of test code)
I have attached the screenshots of three dumps where the difference lies in number of entries stored in java.util.concurrent.ConcurrentHashMap$HashEntry[] which is a managed by CMap.
In screenshots Normal_PL4 and TestCode, size of this array is 16384, but in screenshot of MemoryLeak_PL7
the value is 2097152 which is multiple of 128 times of 16384.
It looks like after the cluster is running for sometime some thread may be blocking in Pl which is not removing the entries from this array, hence once the
chunck of 16384 is filled, again the array is growing with another chunck.
Could you explain which reasons might have triggered the ncontrolled increase of this ConcurrentHashMap array size in CMap.
Regards,
Hari
On Wednesday, 23 January 2013 12:55:17 UTC+8, Hari Poludasu wrote: