Java process memory grows infinitely Memory leak?
We have a java process running on Solaris 10, serving about 200-300 concurrent users Administrators have reported that the memory used in the process increases significantly over time Reach 2GB in a few days and never stop growing
We have dumped the heap and analyzed it using the eclipse memory analyzer, but we can't see any ordinary memory The heap size is very small
After adding the memory status record, for our application, we found that the memory usage reported by the "top" utility used by the administrator is different from that reported by the memorymxbean and runtime libraries
This is the output of both
Memory usage information From the Runtime library Free memory: 381MB Allocated memory: 74MB Max memory: 456MB Total free memory: 381MB From the MemoryMXBean library. Heap Committed: 136MB Heap Init: 64MB Heap Used: 74MB Heap Max: 456MB Non Heap Committed: 73MB Non Heap Init: 4MB Non Heap Used: 72MB Current idle threads: 4 Current total threads: 13 Current busy threads: 9 Current queue size: 0 Max threads: 200 Min threads: 8 Idle Timeout: 60000 PID USERNAME NLWP PRI NICE SIZE RES STATE TIME cpu COMMAND 99802 axuser 115 59 0 2037M 1471M sleep 503:46 0.14% java
How is this possible? The top command reports much more usage I expect res to be close to the heap rather than the heap
PMAP - x, however, reports most of the memory in the heap:
Address Kbytes RSS Anon Locked Mode Mapped File *102000 56 56 56 - rwx---- [ heap ] *110000 3008 3008 2752 - rwx---- [ heap ] *400000 1622016 1621056 1167568 - rwx---- [ heap ] *000000 45056 45056 45056 - rw----- [ anon ]
Can anyone explain this? I'm completely lost
thank you.
to update
This does not seem to be a problem on Linux
In addition, based on Peter Lawley's response, the "heap" reported by PMAP is a native heap, not a Java heap
Solution
In a garbage collection environment, keeping unused pointers is equivalent to "failed to leak" and prevents the GC from performing its work It's really easy
A common culprit is hash tables The other is array or vector logical cleanup (by setting the reuse index to 0), while the contents of the actual array (above the index) still point to something