My server has some kind of memory leak or something, java CPU usage jumps to 100% in an hour and after many hours, it jumps to 1100%.
I was wondering if this loop traversing may cause a memory leak.
for (Object o : friends.values()) {
doSomethingWith(o);
}
friends is a ConcurrentHashMap and it's content may change on some situations when a friend goes online or offline.
If this is safe, how can I find the memory leak?
Thanks in advance.
you can use visualvm to monitor your application while it is running.
Create a memory dump and use Eclipse Memory Analyzer to study your dump
You should be able to get more details with these tools