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

后端 未结 1 843
挽巷
挽巷 2020-11-27 07:53

I have the following host with the memory details:

$free -m
             total       used       free     shared    buffers     cached
Mem:          7872              


        
相关标签:
1条回答
  • 2020-11-27 08:19

    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
    
    0 讨论(0)
提交回复
热议问题