我有一个用于搜索文件的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堆大小
发布评论