How to programmatically increase the Java heap size

I have a java desktop application for searching for files that will soon reach the default heap limit I will not be able to access all the systems that will be installed, so I want to increase the JVM heap size of the application itself Anyone can help me with how to execute programmatically in my application

Solution

Setting - Xmx to a gig does not mean that the JVM will allocate a lot of memory at startup The JVM will allocate only - XMS (plus overhead) until more heap space is required Do you need to protect users from the operating system's virtual memory or memory allocation failure? If not, just set Xmx to a larger value Please note that windows 32-bit JVMs will often ignore Xmx settings greater than 1.2gig, so it's best not to ask for security around a gig

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>