Java process memory growing indefinitely. Memory leak?
<p>We have a java process running on Solaris 10 serving about 200-300 concurrent users. The administrators have reported that memory used by process increases significantly over time. It reaches 2GB in few days and never stops growing. </p>

<p>We have dumped the heap and analysed it using Eclipse Memory Profiler, but weren't able to see anything out of the ordinary there. The heap size was very small.</p>

<p>After adding memory stat logging, to our application we have found discrepancy between memory usage reported by "top" utility, used by the administrator, and the usage reported by MemoryMXBean and Runtime libraries.  </p>

<p>Here is an output from both.</p>

<pre><code>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
</code></pre>

<p>How can this be? top command reports so much more usage. I was expecting that RES should be close to heap+non-heap.</p>

<p>pmap -x , however, reports most of the memory in the heap:</p>

<pre><code>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 ]
</code></pre>

<p>Can anyone please shed some light on this? I'm completely lost.</p>

<p>Thanks.</p>

<p><strong>Update</strong></p>

<p>This does not appear to be an issue on Linux.</p>

<p>Also, based on the Peter Lawrey's response the "heap" reported by pmap is native heap not Java heap. </p>