Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Advice for using -Xmx  RSS feed

 
Cate van Alphen
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My program keeps giving an OutOfMemoryError. Using -Xmx to increase the memory has been suggested, but I was wondering where to find more information about this. Specifically can this be used with an executable jar (if so how - I'm not very knowlegeable about making jar beyond following steps of a tutorial). What is an advisable amount of memory, and what will the effects be of increasing the memory and using the program on other computers. What happens to the machine if I allocate too much? Does it cause death or move on to hard drive memory?

Thanks for any info.
 
Renato Losio
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may help:
http://forum.java.sun.com/thread.jspa?threadID=765037
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

This might help,

http://java.sun.com/docs/hotspot/VMOptions.html
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java heap goes into virtual memory, on popular operating systems. Therefore, the heap size is not limited by the amount of RAM on your system, but rather by the amount of RAM plus swap space (minus space required by OS and all other apps). As previous posters have said, there are also absolute maximum heap sizes various JVMs.

Before increasing heap size, though, you should have a "sanity check" that your program really does need to store lots of data in memory. Perhaps you have a leak (e.g. objects references stored in long-lived collections, so preventing GC) somewhere? Perhaps you could use SoftReference for caching? Perhaps you could store some stuff in files? Etc.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!