Big difference between JVM process size and Memory Heap size

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)

首先推出JFrame

after the second JFrame is launched (image2)

第二次JFrame发布

after the second JFrame is closed (image3)

第二个JFrame关闭

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).

链接地址: http://www.djcxy.com/p/19844.html

上一篇: 堆内存使用情况作为Java程序运行

下一篇: JVM进程大小和内存堆大小之间的巨大差异