Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM Overhead Too Big

Tags:

java

I had memory problems with one server. It's an amazon micro instance, so its memory is very limited (free -m says 603 MB). That's why I started tomcat with

-server -Xmx290m -Xms290m -XX:MaxPermSize=65m

However, the "java" process takes around 86% of the total memory, which is 518M. 518-355 = 163 MB overhead. That looks like a lot, and is suspicious, especially given than:

  • a similar application ran on another jvm version on another micro instance doesn't have overhead this big
  • the same application run locally gives just 40 MB overhead. Locally it runs in Windows 7, 64 bit.

The java version on the problematic server is:

java version "1.7.0_09-icedtea"
OpenJDK Runtime Environment (amzn-2.3.3.13.amzn1-x86_64)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

The big discrepancy between the local runtime and the one on the server makes me exclude the option that there are some expensive off-heap objects (e.g. byte buffers) in the application (and I'm not using any of that anyway). I know that the JVM overhead varies, but having more than 1/2 of the heap as overhead sounds too big. So what could be the reason for that? Or is it a normal way of things?

like image 410
Bozho Avatar asked Jan 03 '13 07:01

Bozho


1 Answers

The choice of GC may impact heap size overhead, since each GC scheme must set aside some memory to manage your heap. Also, on such a small VM, you may not benefit much from going 64bit. A 32bit jvm will take up less heap, even when using CompressOOPS, which should be on by default. So play with your favourite garbage collectors, pick the one that gives the best mix of overhead and latency for you.

like image 127
Ralf H Avatar answered Sep 30 '22 23:09

Ralf H