Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 30-10-2009
Member
 
Join Date: Aug 2009
Posts: 124
Distribution of the Java memory

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?
Reply With Quote
  #2  
Old 30-10-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Distribution of the Java memory

The JVM allocates memory in advance, so the process takes more space than it actually uses. You can see the difference with a tool such jvisualvm (included with the JDK since version 1.6b10) which allows you to view memory.
Reply With Quote
  #3  
Old 30-10-2009
Member
 
Join Date: Aug 2009
Posts: 124
Re: Distribution of the Java memory

Maybe I missed something with jVisualVM, but I do not see how to explore something other than the heap. But I have no problem with the heap.

Can you tell me how I should proceed to explore what is neither in the heap nor in the perm space or in the stacks? I assume that what remains is the responsibility of native libraries and buffers with the OS, but how to learn more?
Reply With Quote
  #4  
Old 30-10-2009
Member
 
Join Date: Nov 2008
Posts: 996
Re: Distribution of the Java memory

Have you checked the memory actually used with

cat /proc/<pid>/status

VIRT column in top is that information on the address space used by the application, it has nothing to do with the memory it has reserved and is not an indication of needs memory in your application. If I create a C application that is able to work with 100k of memory but that is a 5 -mmap file 100G, I have a VIRT Alegre exceeding 500G.

It 'just' what have 1 page of data mapped in the area of addressing 16G, for example, with a big hole of 15.99 billion between it and the base of your program, so that the column of VIRT 16G gives your process.

I manage, no problem here, to push the VIRT a JVM (ok, I push the cap but good) to 2.5 tera memory, yet as great, the JVM throws out of memory exceptions when j 'reaches the 512M authorized by their orders without really require from system memory.

In short, the VIRT column is certainly not to be taken into account when measuring the need for an application (or java or any other). The most similar is in the area [-RES SHR, RES] when you did not swap.

And unlike VIRT / RES is absolutely not related to the difference permsize / MaxPermSize, HEAPSIZE / maxheapsize because this management is unknown to the bone, which is the jvm or not allocate memory segment based on supported via calls realloc ()

There are plenty of things that can increase the address space in an application without requiring the RAM because full operating system are based on page address (access to the device, access to flat files, access to shared resources, inter-process communication, etc.).
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Distribution of the Java memory"
Thread Thread Starter Forum Replies Last Post
How to install Java games in the memory card of Samsung SGH-E250 Python$ Portable Devices 4 30-01-2012 06:12 PM
Detect memory leak in java Isabella Software Development 8 14-11-2011 11:56 AM
java- store a web page in memory arvindikchari Software Development 1 15-06-2011 12:19 AM
Memory error in java Maya Angelou Software Development 5 10-03-2010 01:34 PM
Access memory address in java Kingfisher Software Development 5 15-01-2010 02:40 PM


All times are GMT +5.5. The time now is 04:51 AM.