Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relation between memory host and memory arguments xms and xmx from Java

I have the following host with the memory details:

$free -m
             total       used       free     shared    buffers     cached
Mem:          7872       7579        292         17        483       3983
-/+ buffers/cache:       3112       4759 
Swap:         2047         14       2033

I have a java app running with the params -Xms200m -Xmx200m, could someone please explain me why the VCZ is 3800076 and the RSS is 241304 (which is more of the Java params)

from the ps -aux command:

66345     6773  0.2  2.9 3800076 241304 ?      Sl   Apr1  12:06 /apps/myapps/myapp1/java/bin/java -Xms200m -Xmx200m
like image 817
Weslor Avatar asked Apr 26 '16 18:04

Weslor


People also ask

What is Xms and XMX parameter in Java?

The flag Xmx specifies the maximum memory allocation pool for a Java virtual machine (JVM), while Xms specifies the initial memory allocation pool. This means that your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory.

What does Xms and XMX signify when starting a JVM?

The flag Xmx specifies the maximum memory allocation pool for a Java Virtual Machine (JVM), while Xms specifies the initial memory allocation pool.

What is Xms in Java arguments?

-Xms. The -Xms option sets the initial and minimum Java heap size. The Java heap (the “heap”) is the part of the memory where blocks of memory are allocated to objects and freed during garbage collection. Note: -Xms does not limit the total amount of memory that the JVM can use.


1 Answers

Memory used by Java process (as seen by the OS) is not only limited to Java Heap. There are a lot more memory areas that should be also counted:

  • Metaspace (where class metadata resides);
  • Code Cache (storage for JIT-compiled methods and all the generated code);
  • Direct ByteBuffers;
  • Memory-mapped files, including files mapped by JVM, e.g. all JAR files on the classpath;
  • Thread stacks;
  • JVM code itself and all the dynamic libraries loaded by Java Runtime;
  • Other internal JVM structures.

Use NativeMemoryTracking JDK feature to get the detailed breakdown of memory areas used by JVM:

java -XX:NativeMemoryTracking=detail -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMTStatistics
like image 171
apangin Avatar answered Oct 20 '22 18:10

apangin