简体   繁体   中英

How to increase heap size in java?

I create the autorun cd of which contains the dicom images. it taks arround 10-15 min. to display dicomviewer on screen. so, I want to increase the jvm heap size at runtime, programatically,(not from the commandline) suppose i have to allocate 500mb to my app when i start the app. is it possible? i am using windows platform.

Literally, no. The max heap size is set at JVM launch time and cannot be increased.

In practice, you could just set the max heap size to as large as your platform will allow, and let the JVM grow the heap as it needs. There is an obvious risk in doing this; ie that your application will use all of the memory and cause the user's machine to grind to a halt. But that risk is implicit in your question.

One approach you can take in a Windows environment is to install a service that starts up your application. Via this method you can make the windows service point to a wrapper file that calls all the relvant files to start up your application. Here you can specify something like;

set JAVA_OPTS=-Xrs -Xms6G -Xmx6G -XX:MaxPermSize=384M 

You can use this to specify your JVM memory settings on startup.

Please see http://docs.oracle.com/cd/E19900-01/819-4742/abeik/index.html for more information about the parameters.

Hope this helps,

V

Since the problem is about the duration of the pictures display and knowing that you cannot change the heap size programmatically, what about optimizing your program to load the pictures faster ?

You can use multiple threads or asynchronous loading to speedup the display. You may also use paging in the user interface.

Can you edit the code of the user interface ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM