File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes java.lang.OutOfMemory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java.lang.OutOfMemory" Watch "java.lang.OutOfMemory" New topic


Robin Richardson
Ranch Hand

Joined: Mar 01, 2001
Posts: 37
I'm working on a major project. Using the my program in a development setting everything works well. Trying to move to the real thing (with alot more empty database columns) I get a java.lang.OutOfMemory error.
Any suggestions on where to look, or what to look for?
Suresh Bansal
Ranch Hand

Joined: Jul 23, 2001
Posts: 91
You can try the following.
If its GUI, You can set the swing components to null.
In JDBC, close the result set after query.

Journey is as important as the Destination.<br /> <br />PMP, SCJP, SCJD, SCEA (Part 1), SCMAD, SCDJWS
A Agrawal
Ranch Hand

Joined: Jul 13, 2001
Posts: 41
Try calling System.gc(); at regular interval..
close all the resources once you have finished using them and explicitly set object references to null. e.g. if you are using a vector and adding some element to it on the run.. you can help JVM by removing all elements/setting it to null once you are done.
Do all the cleanup in finally block to make sure that it happens irrespective of whether your program faces any exception or not.
JDBC is very costly in memory related issues�so don�t forget to close connection if you are opening in your program.
And even if you still get this exception, try after increasing virtual memory(if using windows) otherwise only increasing RAM will help.
Good Luck.

Amit Agrawal,
New Delhi, India.

Amit Agrawal,<BR>New Delhi, India.
I agree. Here's the link:
subject: java.lang.OutOfMemory
It's not a secret anymore!