I'm trying to understand how memory is incorporated in a Java process. What I understood is that there is the heap (controlled by -Xmx and -Xms), the perm space (controlled -XX:MaxPermSize and -XX:PermSize), the code cache (controlled-XX:ReservedCodeCacheSize and -XX:InitialCodeCacheSize) and the stack per thread (controlled by -Xss and -XX:ThreadStackSize).
From there, I'd imagine that adding all this, I had to get very nearly the size of memory allocated to the process. Well no! I have two examples, both web applications under Tomcat 6 with JDK 6. Both in the first case, I've never been alerted, as in the second case, the difference is significant and can cause me problems.
First case:
Under Linux 64bits : heap + perm + code cache=4096 MB, StackSize=1MB with 21 threads
If I add up everything, I get 837 MB, while my process uses 873 MB.
Second case:
Under Linux 64bits : heap + perm + code cache=4096 MB, StackSize=1MB with 250 threads => 4350 MB, and my process uses 1500 MB more!
Which side should I look to find what occupies my 1500 MB?
Bookmarks