my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes java.lang.OutOfMemoryError: Java heap space Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "java.lang.OutOfMemoryError: Java heap space" Watch "java.lang.OutOfMemoryError: Java heap space" New topic

java.lang.OutOfMemoryError: Java heap space

J Vazquez

Joined: Aug 24, 2008
Posts: 6
I am using the following code to get ImageIcons from files on my computer to display on jbuttons. After about 4(80x60) images are displayed on my JPanel, I get this error

java.lang.OutOfMemoryError: Java heap space

Any Ideas on what can be done? I read about increasing the memory via the commandline, if this is the case, how do I incorporate that into my program if I plan on distributing it to friends? Thanks
Steven Wall

Joined: Nov 04, 2007
Posts: 22
If you are distributing your application via Java WebStart, in your JNLP file, there is a <j2se> node that is child node of <resources>. On the <j2se> node, there is an attribute for "max-heap-size". You can set the client heap size there.

For example:

J Vazquez

Joined: Aug 24, 2008
Posts: 6
Does anyone see an error in this.. I am running this on os 10.5 if that matters.
It is sorta covered in the JavaRanch Style Guide.
subject: java.lang.OutOfMemoryError: Java heap space
Similar Threads
JButton slow response time
how to load compressed tiff image formats with JIMI
BufferedImage OutOfMemoryError
Dealing with images
very simple question...