Java application to use maximum available memory in the system

半腔热情 提交于 2019-11-29 21:16:36

问题


There are -Xmx and max-heap-size (jnlp) options to set maximum memory java application can use.
If these options are not specified application is permitted to use only small amount of available phisical memory in the system.
That is the reason people play with -Xmx to allow application to use more memory. But this is really a nightmare as for me because there could be different amont of memory on client machine and even OS should be taken into consideration.

Is there any way to alow java application to use maximum available memory in the system?

Thanks.


回答1:


-XX:DefaultMaxRAMFraction=1

bugs.sun.com
Sun's 1.5 JVM
Default Heap Size

Doesn't work for web start.




回答2:


Unfortunately, the best way I'm aware of is to write a simple launcher (possibly a shell script or batch file) that inspects the system, determines an appropriate value for -Xmx, and then launches the Java application. Once the JVM has initialized, it is not possible to change the values.



来源:https://stackoverflow.com/questions/11366177/java-application-to-use-maximum-available-memory-in-the-system

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!