Java堆Xms和Linux可用内存不同 [英] Java heap Xms and linux free memory different

查看:348
本文介绍了Java堆Xms和Linux可用内存不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在centos Box中运行一个Java程序. 我的-Xmx和-Xms设置为4000 Mb.

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

程序运行正常.

The program works fine.

但是当我执行free -m时,已用内存显示为506 MB.据我了解,XMS内存应为JVM保留.Why does free command not showing the java used memory ?

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 ?

我还完成了jstat -gccapacity $(pidof java),并且更新了NGCMN和NGCMX并具有相同的值? 任何支持都会有所帮助. 我正在以 java -Xms41000m -Xmx42000m -jar

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

推荐答案

即使-Xmx-Xms设置为相同的值,为Java Heap保留的空间也不会立即在RAM中分配.

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

操作系统通常仅在首次访问虚拟页面时才延迟分配物理内存.因此,虽然未触及Java Heap的未使用部分,但实际上并不会消耗内存.

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.

您可以使用-XX:+AlwaysPreTouch选项强行触摸JVM启动时的所有堆页面.

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

这篇关于Java堆Xms和Linux可用内存不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆