简体   繁体   中英

Java virtual heap space

My application has a feature that generates images(jpg) , it uses a lot of heap space (more then allowed on host server). Is their any way i can make it to use less heap memory. I mean, just like our Computers uses virtual memory when RAM is full. Is their any way for java to use external memory as virtual heap space ?

Technically speaking, no. That's up to the OS (check Michael Wiles answer).

Broadly speaking, yes: once you generate a JPG and it's no longer immediately used, write it to disk and destroy the object representing it (holding its data). This is slower, but will use less RAM.

Just run the java app with -Xmx4g or something. This will allow the java vm to use 4 gigs of ram regardless of how much ram the system has. When the java VM asks for more memory than RAM is available the host OS will provide the memory as virtual memory.

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