Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

jvm - Java heap Xms and linux free memory different

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...