• Post Reply Bookmark Topic Watch Topic
  • New Topic

JVM Memory  RSS feed

 
Mike Rolf
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application, which deals with large data sets, is throwing a java.lang.OutOfMemoryError error.

From what I've read on the web it looks like I need to increase of the memory of the JVM. I've read I can use the -Xmx command.

Can someone confirm if this is the command I should use, and what a 'reasonable' size to increase it to is?

i.e. -Xmx256m, is that reasonable?

Thanks,

Mike
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, -Xmx sets the maximum size of the JVM (The default value is 64MB).
The "reasonable" size is determined by the requirements of your program (don't set to a gig if you only need 256MB) as well as the physical RAM on your machine.
Java Command Documentation
 
Mike Rolf
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joe, one more question how would I go about working out how much memory my app needs? At the moment all I'm seeing is an OutOfMemoryError.

Mike
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could just keep increasing -Xmx until the program works. If there's no major changes to the data sets or code, you should be fine.
Java has built in tools to monitor resources so you should be able to get an idea as to how much is being used and if the -Xmx setting is way out of line.
 
Mike Rolf
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just went for the trial & error approach and kept increasing the size of the memory until it worked. I now have it set to 512Mb and my application seems to work fine.

Thanks for your help Joe.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!