• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JVM Memory

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic