简体   繁体   English

Java:Mac与JVisualVM上的Activity Monitor中的内存消耗

[英]Java: Memory consumption in Activity Monitor on Mac vs JVisualVM

I am trying to develop a voxel rendering engine in Java with LWJGL 2. 我正在尝试使用LWJGL 2在Java中开发体素渲染引擎。

I'm launching my application from Eclipse, and I've set the initial heap size to 1024M and the max heap size to 2048M in the "Run Configurations" menu. 我正在从Eclipse启动应用程序,并在“运行配置”菜单中将初始堆大小设置为1024M,将最大堆大小设置为2048M。

When I look at the memory consumption of my program in Java VisualVM, it shows about 500-1000 MB of used heap to me. 当我查看Java VisualVM中程序的内存消耗时,它向我显示了大约500-1000 MB的已用堆。

Diagram of memory consumption in Java VisualVM Java VisualVM中的内存消耗图

图

But, the Activity Monitor on Mac shows me that there are 20 GB of RAM used. 但是,Mac上的活动监视器向我显示已使用20 GB的RAM。 What could be possible reasons for this enormous discrepancy? 这种巨大差异的可能原因是什么?

The heap size is only used by plain Java objects. 堆大小仅由普通Java对象使用。

If you are using a native library like LWJQL you can allocate far more native memory. 如果您使用的是LWJQL之类的本机库,则可以分配更多的本机内存。

These native data object often needs to be explicitly freed by calling a method on the object when you don't need it anymore. 当您不再需要本机数据对象时,通常需要通过在该对象上调用方法来显式释放它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM