why was the Java process memory is more then the heap allocated in Xmx ?

if we verify the Weblogic java process memory on the task manager or top output you will notice more memory consumption then the allocated value of Xmx value in the JVM argument for max heap memory .

It is common to notice that the memory of the java process is greater than the value of the max heap defined for the JVM .

In the Java process memory is used for the following things

  1. Java heap
  2. Native C-heap
  3. libraries
  4. jar files
  5. war files
  6. stack
  7. Anonymous memory

The -Xmx switch which we have used during your start-up scripts is limiting the memory consumed by your application heap. Besides heap memory, the java application process uses other part of the memory.

Java Process Memory= Max Heap Memory(Xmx) + Max PermGeneration Memory + Native Memory

Total memory utilization of the JVM process consist of more things than just the Java heap. The jvm process uses more memory for various reasons. Below are few examples:

JNI Code
JIT Optimization
Loaded libraries (including jar and class files)
Thread Stacks
Garbage Collection etc.,

Hence, it is not unusual to see the total memory for a Java process to be significantly greater than the size of the Java heap.

Will see what is the definitions of each of the above mentioned terminologies for better understanding .

Max Heap Memory(Xmx) means the maximum heap allocated for the JVM . This much free memory is selected from RAM during JVM startup if the values for Xms and Xmx are same .other wise Xms amount of memory is used for JVM startup and the heap grows till Xmx value . All the vendors recommended to use both Xms and Xmx values to the same to minimize the GC interval during the lifecycle for JVM .

PermGeneration Memory JVM also has an internal representation of the Java classes and those are stored in the permanent generation. Class definitions are stored here, as are static instances. The PermGen is garbage collected like the other parts of the heap.
PermGen contains meta-data of the classes and the objects i.e. pointers into the rest of the heap where the objects are allocated. The PermGen also contains Class-loaders which have to be manually destroyed at the end of their use else they stay in memory and also keep holding references to their objects on the heap. PermGen always has a fixed maximum size. PerGen space cannot be made to auto increase so it is difficult to tune it. if the max permgen memory is enough then class loading itself will fail during JVM startup .

Native memory means the memory area outside normal JVM heap, but still within the total user space memory spared by OS for JVM process .This may contains the Native libraries like C,C++ etc required for the JVM class loaders .

Related Posts

Leave a Reply

Your email address will not be published.