来自Java的内存主机和内存参数xms和xmx之间的关系 [英] 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
我有一个使用params -Xms200m -Xmx200m
运行的java应用程序,有人可以解释一下为什么VCZ是3800076和RSS是来自 ps -aux
命令的241304(更多Java参数)
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)
:
66345 6773 0.2 2.9 3800076 241304 ? Sl Apr1 12:06 /apps/myapps/myapp1/java/bin/java -Xms200m -Xmx200m
推荐答案
Java进程使用的内存(如操作系统所见)不仅限于Java堆。还有更多的内存区域应该计算在内:
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:
- 元空间(类元数据所在的位置);
- 代码缓存(JIT编译方法的存储和所有生成的代码);
- 直接ByteBuffers;
- 内存映射文件,包括由JVM映射的文件,例如类路径上的所有JAR文件;
- 线程堆栈;
- JVM代码本身以及Java Runtime加载的所有动态库;
- 其他内部JVM结构。
- 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.
使用 NativeMemoryTracking JDK功能,用于获取JVM使用的内存区域的详细分类:
Use NativeMemoryTracking JDK feature to get the detailed breakdown of memory areas used by JVM:
java -XX:NativeMemoryTracking=detail -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMTStatistics
这篇关于来自Java的内存主机和内存参数xms和xmx之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!