JVM进程大小和内存堆大小之间的巨大差异 [英] Big difference between JVM process size and Memory Heap size

查看:267
本文介绍了JVM进程大小和内存堆大小之间的巨大差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 8.1 64bit上开发java swing应用程序,带有4GB RAM, JDK版本8u20 64bit。



问题出在我发布的时候带有 Netbeans Profiler 的应用程序与监视器选项。



当加载第一个Jframe时,应用程序内存堆大约 18mb 和JVM进程大小 50mb(image1)



然后当我启动包含带有webView的JFxPanel的其他Jframe时,Heap跳转到 45mb 并且JVM进程非常快地跳到 700mb(image2),这非常令人困惑。
然后,当我关闭第二个JFrame并且它被释放并调用System.gc()并且JVM执行GC(在大多数情况下)时,堆落到 20mb 附近但是JVM进程永远不会丢弃(image3)



为什么内存堆(45 Mb)和JVM进程(699 Mb)之间存在巨大差异?
为什么JVM需要所有内存?以及如何减少这个数额?
我正在推出带有这些虚拟机选项的应用程序:

  -Xms10m -Xmx60m -Xss192k 
- XX:+ UseG1GC -XX:MinHeapFreeRatio = 5
-XX:MaxHeapFreeRatio = 10 -XX:PermSize = 20m
-XX:MaxPermSize = 32m

编辑: - 我刚刚阅读该链接中的问题 64位版本不包含JRE中的客户端文件夹,将忽略-client参数。



结果是当第二个JFrame打开并且堆大小(在中)时,总内存进程跳转到 540Mb 三点)几乎与64位v中的数字相同ersion,这是否证实这是与JVM相关的问题(相同的堆大小和总过程大小的 260Mb 差异)?

解决方案

虚拟内存分配大多无关紧要(参见解释这个答案)与实际内存使用情况大不相同。 JVM不是为限制虚拟内存分配而设计的,请参阅有关限制虚拟内存使用情况的问题。

最终用户可能会在任务管理器中看到大量的虚拟内存使用情况,但这几乎毫无意义。 Windows任务管理器中显示的内存使用的不同数字在本文。总结:在Windows任务管理器中查看内存(私有工作集)和页面错误增量(后者的相关性在这个答案)。


I am developing java swing application on Windows 8.1 64bit with 4GB RAM with JDK version 8u20 64bit.

The problem is when I launched the application with Netbeans profiler with Monitor option.

When the first Jframe is loaded the application Memory Heap is around 18mb and the JVM process size around 50mb (image1).

Then when I launch the other Jframe which contains a JFxPanel with webView the Heap jumps to 45mb and the JVM proccess jumps to 700mb very fast (image2) which is very confusing. Then when I close the second JFrame and it get disposed and a System.gc() is called and the JVM perform a GC (in most times) the heap drops to around 20mb but the JVM proccess never drops (image3).

Why there is a huge difference between memory Heap (45 Mb) and JVM proccess (699 Mb)? Why the JVM needs all that Memory? And how to reduce that amount? And I am launching the app with those vm options:

-Xms10m  -Xmx60m -Xss192k
-XX:+UseG1GC -XX:MinHeapFreeRatio=5
-XX:MaxHeapFreeRatio=10  -XX:PermSize=20m
-XX:MaxPermSize=32m  

EDIT :- I just read the question in that link JVM memory usage out of control and he have the same problem but the situation is different his heap size is arround 33% of the total JVM process memory size which is in my case less than 7% and he is doing multiple jobs simultaneously (Tomcat webapp) which I don't (java swing application) and he didn't launch his application with the same VM arguments I did.

UPDATE :- after the first JFrame is launched (image1)

after the second JFrame is launched (image2)

after the second JFrame is closed (image3)

EDIT 2 :- I just tried the same application with the same VM arguments above and added

-client 
-XX:+UseCompressedOops 

and used JDK 8u25 32-bit because as mentioned in this answer https://stackoverflow.com/a/15471505/4231826 the 64-bit version doesn't include client folder in the JRE and will ignore -client argument.

The result is that the total memory process jumped to 540Mb when the second JFrame was open and the heap sizes (in the the three points) were almost the same numbers as in the 64-bit version, Does this confirm that this is a problem related to the JVM (The same heap sizes and a 260Mb difference in total process sizes)?

解决方案

Virtual memory allocation is mostly irrelevant (see for an explanation this answer) and very different from actual memory usage. The JVM is not designed to limit virtual memory allocation, see the question about limiting virtual memory usage.
The end-user may see a lot of virtual memory usage in the task-manager, but that is mostly meaningless. The different numbers for memory usage shown in the Windows task manager are explained in this article. In summary: in the Windows task manager look at the "Memory (Private Working Set)" and "Page Fault Delta" (the relevance of the latter is explained in this answer).

这篇关于JVM进程大小和内存堆大小之间的巨大差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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