如何以编程方式增加Java堆大小

编程入门 行业动态 更新时间:2024-10-28 04:24:57
本文介绍了如何以编程方式增加Java堆大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个用于搜索文件的java桌面应用程序,它通常很快就会达到默认的堆限制。我无法访问将要安装的所有系统,因此我想在应用程序本身中增加JVM堆大小。任何人都可以帮助我如何在我的应用程序中以编程方式执行此操作

I have a java desktop application for searching files and it is usually reaching the default heap limit pretty soon. I wont have access to all the systems it will be installed in so I want to increase the JVM heap size in the application itself. Can anybody help me how can I do that programmatically in my application

推荐答案

将-Xmx设置为一个演出并不意味着JVM将在启动时分配大量内存。 JVM将仅分配-Xms(加上开销),直到需要更多堆空间。您是否需要保护您的用户免受虚拟内存抖动或操作系统内存分配失败的影响?如果没有,只需将Xmx设置为较大的值即可。请注意,Windows 32位JVM通常会忽略大于1.2Gig的Xmx设置,因此最好不要求大于gig的安全性。

Setting -Xmx to one gig doesn't mean that the JVM will allocate that much memory upon start-up. The JVM will allocate only -Xms (plus overhead) until more heap space is needed. Do you need to protect your users from thrashing virtual memory or a failed memory allocation from the OS? If not, just set Xmx to a large value. Note that Windows 32bit JVMs will often ignore Xmx settings greater than 1.2Gig, so it's best to not request more than a gig or so to be safe.

更多推荐

如何以编程方式增加Java堆大小

本文发布于:2023-07-27 05:21:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1220579.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大小   方式   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!