• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Out of Java heap space

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just got java.lang.OutOfMemoryError: Java heap space erro when trying to run my program. I tried to put my max memory up to 500MB. But still getting the same error.
Tho I don't actually belevie that my program should even be using that much memory. It propably has 1000 lines of code. And even that is very optimistic guess. And all it does is make some SQL queries.
So how should I start to determine what is the problem. Maybe some kind of memory leak or someting. This is really the first time I'a, meeting this troblem.
Here's the error message:
[code]
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:3209)
at java.lang.String.<init>(String.java:216)
at java.lang.StringBuilder.toString(StringBuilder.java:430)
at javax.swing.JRootPane.createLayeredPane(JRootPane.java:490)
at javax.swing.JRootPane.<init>(JRootPane.java:348)
at javax.swing.JFrame.createRootPane(JFrame.java:260)
at javax.swing.JFrame.frameInit(JFrame.java:241)
at javax.swing.JFrame.<init>(JFrame.java:164)
at tietaexpress.Searchpanel.<init>(Searchpanel.java:25)
at tietaexpress.PersonTable.<init>(PersonTable.java:12)
at tietaexpress.Searchpanel.<init>(Searchpanel.java:22)
at tietaexpress.PersonTable.<init>(PersonTable.java:12)
at tietaexpress.Searchpanel.<init>(Searchpanel.java:22)
at tietaexpress.PersonTable.<init>(PersonTable.java:12)
at tietaexpress.Searchpanel.<init>(Searchpanel.java:22)
...
[code]

Yes. I know it must be frustrating to solve other peoples stupid errors. But try to bear with me :>
Thanks.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this was my problem I would very carefully work through what happens to the various objects created for a single DB query.

Are they being properly closed and disposed of?

The arrayCopy called from swing methods suggests you may not be properly disposing of swing graphic objects - the primary cause of problems here are listeners attached to controls that are not properly released and thus prevent swing objects from being garbage collected.

Bill
 
Joonas Järvinen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'am not sure about the second part. Yet. But about the sql inqueries. This error comes when I'am only starting the application. So I'am not yet doing any sql commands. I'am not even connected to the database at this point.
But I try to look in to the second part of your post.
 
Joonas Järvinen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
About releasing Swing objects. How do I do it? I remember reading this some where. But I tought that in Java one does not need to worry about over usage of memory in this section. Because Java does it automatically. Unlike ie. C++.
 
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

Joonas Järvinen wrote:Because Java does it automatically. Unlike ie. C++.



Java handles the low-level details of allocating memory, so there's no calls to malloc or free. The programmer is still responsible for the proper use of creating and tracking high-level details, like creating object instances and making sure they're available to the garbage collector.

Joonas Järvinen wrote:About releasing Swing objects. How do I do it?


Any object that has an addListener method will have a corresponding removeListener method.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joonas Järvinen wrote:This error comes when I'am only starting the application. So I'am not yet doing any sql commands. I'am not even connected to the database at this point.


...
at tietaexpress.PersonTable.<init>(PersonTable.java:12)
at tietaexpress.Searchpanel.<init>(Searchpanel.java:22)
...

These packages/classes are from your own code, right ? Maybe there's a form or something that's already populated when you launch the app ? What's that searc panel ? If it has say a combo with all your users in, it might try get those from DB at startup.

Otherwise try to increase the memory params, say :
-Xms256m -Xmx768m -XX:MaxPermSize=256m
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic