Search code examples
javamemoryheap-memoryjsvc

Java application running as jsvc uses more memory than Heap+PermGen


i have the following server:

  • Ubuntu Server 12.04 LTS 64Bit
  • No GUI, just command line
  • 4GB RAM
  • 2 Cores
  • Nothing else is running besides Nagios NRPE and Webmin
  • vm.swappiness = 0

Nothing special here, running a Java application:

  • running 24/7 as daemon using jsvc
  • -Xmx2500M
  • -XX:+UseConcMarkSweepGC
  • other settings are not made
  • Using OpenJDK 7
  • JMX Server enabled, and checking every minute by nagios

However, this should not use up all memory and causes the java application to not answer to nagios via JMX.

Why is this using up all my memory and creating SWAP?


Solution

  • Your -Xmx2500M is the maximum heap size available inside your java application. The overhead of running the JVM and managing the objects in that heap is usually 50% more but can be double the heap size. Linux top command will show this in the virtual memory usage.

    A good discussion of non-heap memory usage can be found in the presentation linked here. There is another SO thread on this topic here

    One quick check you can do with OpenJDK on ubuntu is to run jps to see which process ID it is, then jconsole, select the memory tab, then select the non-heap memory usage.

    If you are attempting to run without swap my guess is you will need to experiment with different heap sizes to see what scenario your application can run. .