Java heap Xms and linux free memory different

孤人 提交于 2019-12-17 13:50:34

问题


I have a java program running in centos Box. My -Xmx and -Xms set to 4000 Mb.

The program works fine.

But when i do free -m , the used memory is showing as 506 MB. As per my understanding , XMS memory should be reserved for JVM.Why does free command not showing the java used memory ?

I have also done jstat -gccapacity $(pidof java) and there NGCMN and NGCMX updated and have the same value ? Any support would be helpful. I'm running my program as java -Xms41000m -Xmx42000m -jar


回答1:


Even when -Xmx and -Xms set to the same value, the space reserved for Java Heap is not immediately allocated in RAM.

Operating System typically allocates physical memory lazily, only on the first access to a virtual page. So, while unused part of Java Heap is not touched, it won't really consume memory.

You may use -XX:+AlwaysPreTouch option to forcibly touch all heap pages on JVM start.



来源:https://stackoverflow.com/questions/48982636/java-heap-xms-and-linux-free-memory-different

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!