强制jvm返回原生内存 [英] force jvm to return native memory

查看:153
本文介绍了强制jvm返回原生内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在eclipse任务中运行,需要非常大量的内存。所以jvm当任务运行时吞下约2-3gb的RAM,没关系。但是一旦jvm占用了内存,它不会释放它,并且我有一种情况,当堆中使用的内存大约是200MB,总堆大小约3gb,而且其他程序正在为内存挨饿,这是非常不需要的。



我试过 Max / MinHeapFreeRatio 参数,以强制jvm减少未使用的内存的消耗。那是我的eclipse config.ini 文件:

  -startup 
plugins / org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins / org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502
-vm
c:/ Program Files / Java / jdk1.6.0_26 / bin / javaw.exe
-showlocation
-product
org.eclipse.epp.package。 jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Duser.name = Michael Nesterenko
-Dosgi.requiredJavaVersion = 1.5
-Xms512m
-Xmx4096m
-XX:MinHeapFreeRatio = 10
-XX:MaxHeapFreeRatio = 30

但是这没有帮助,我仍然有很多未使用的内存的情况。

解决方案

当Java启动时,Java会分配最大堆大小ual记忆由于它使用内存,它被分配为真正的主内存。它从未缩小这个尺寸。释放此内存的唯一方法是程序退出。



Java将压缩其内存使用量,以前使用的许多页面可以交换到磁盘,不过,如果再次需要它,这可能会有很大的性能。


I am running from time to time in eclipse tasks that require very big amount of memory. So jvm while task is running swallows about 2-3gb of RAM, that is ok. But once jvm took that memory it does not release it and I have a situation when used memory in the heap is about 200mb with total heap size about 3gb and that is really unwanted as other programs are starving for memory.

I tried Max/MinHeapFreeRatio parameters to force jvm to reduce consumption of an unused memory. That is my eclipse config.ini file:

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502
-vm
c:/Program Files/Java/jdk1.6.0_26/bin/javaw.exe
-showlocation
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Duser.name=Michael Nesterenko
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx4096m
-XX:MinHeapFreeRatio=10
-XX:MaxHeapFreeRatio=30

But that does not help, I still have situations when there are lots of unused memory.

解决方案

Java allocates the maximum heap size when it starts as virtual memory. As it uses the memory it get allocated as real main memory. It never shrinks this size. The only way to release this memory is for the program to exit.

Java will compact its memory usage so many of the pages it has used before can be swapped to disk, however this can have a significant performance hit if it needs them again.

这篇关于强制jvm返回原生内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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