Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

how to overcome  "java.lang.OutOfMemory" Error

Thread view: 
Ananth - 03 Mar 2008 12:38 GMT
We already increased the Heap Space, But still i am getting this
error. Actually we did increase the heapspace upto 1024MB. still java
process eating memory. After that application crashes. I already
search so many sites in Google. Can anybody shed some light on this
issue?
Thomas Kellerer - 03 Mar 2008 12:58 GMT
Ananth, 03.03.2008 13:38:
>  We already increased the Heap Space, But still i am getting this
> error. Actually we did increase the heapspace upto 1024MB. still java
> process eating memory. After that application crashes. I already
> search so many sites in Google. Can anybody shed some light on this
> issue?

There are two possible reasons:

1) you have a memory leak in your program (i.e. objects that are still referenced but no longer needed, so they cannot be garbage collected)

2) your program simply needs that much memory. Either you algorithm requires to hold that much data in memory, then you are out of luck, or you can rewrite the algorithm (e.g. not reading  all 10 million rows from the database table or a 500MB XML file into a DOM tree or whatever you are doing there)

Thomas
siddharathadhumale@gmail.com - 03 Mar 2008 13:48 GMT
> Ananth, 03.03.2008 13:38:
>
[quoted text clipped - 11 lines]
>
> Thomas

Hi
The simple way to get out of this situation is to follow the following
give step
1) Increase the size of Heap Space, as you have already said that you
had increased the size to 1024MB as per my knowledge it is more than
enough.
2) Please look up your code especially by using some external IDE i.e.
Eclipse, Weblogic IDE this type of tool gives you at the coding level
only the object which are created but not used in the class, so that
you can remove.
3) If possible try to run system.gc() (Not much sure, but still can't
say anything this might be helpful to you tooo.)
4) If required please see the performace graph using some tool like,
JProbe etc which will give you the memory leackage point in your
application
Regards
Siddharatha Dhumale
Lew - 03 Mar 2008 14:01 GMT
> 3) If possible try to run system.gc() (Not much sure, but still can't
> say anything this might be helpful to you tooo.)

This will be useless.  Don't bother with System.gc().  (Not "system" -
spelling counts!)

Thomas gave you the best advice.  A profiler can help identify where the leak is.

So can really, really rigorous reasoning about the source code.  Memory leaks
in Java come from repeatedly keeping a reference after it isn't needed, such
as by putting it into a collection like a Map.  The solution is to use
"temporary" variables that go out of scope (the block ends) as the only
references to such objects.  Avoid static and collection references to objects
that need to go away.

If your algorithm simply demands gigabytes (or gibibytes) of data, either you
are going to have to stripe the algorithm or buy more RAM.

Signature

Lew

Roedy Green - 03 Mar 2008 23:16 GMT
> We already increased the Heap Space, But still i am getting this
>error. Actually we did increase the heapspace upto 1024MB. still java
>process eating memory. After that application crashes. I already
>search so many sites in Google. Can anybody shed some light on this
>issue?

see http://mindprod.com/jgloss/packratting.html
http://mindprod.com/jgloss/profiler.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Jason Cavett - 04 Mar 2008 15:12 GMT
On Mar 3, 6:16 pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:

> > We already increased the Heap Space, But still i am getting this
> >error. Actually we did increase the heapspace upto 1024MB. still java
[quoted text clipped - 7 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

Good articles.  Thank you very much.  Appreciate it.
Jason Cavett - 04 Mar 2008 19:40 GMT
On Mar 3, 6:16 pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:

> > We already increased the Heap Space, But still i am getting this
> >error. Actually we did increase the heapspace upto 1024MB. still java
[quoted text clipped - 7 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

So, I'm curious because I noticed you said that Images need to be
flushed.  What happens in the case when an Image is not actually
created, but only set...such as...

someObject.setImage(anImageIcon.getImage());

How is that handled?  Should I be handling it?

Very informative site, BTW.  Thank you for the link.
Roedy Green - 05 Mar 2008 08:05 GMT
On Tue, 4 Mar 2008 11:40:35 -0800 (PST), Jason Cavett
<jason.cavett@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>someObject.setImage(anImageIcon.getImage());
what type is someObject. There is no method Object.setImage.

Presumably when you were done with the image you might
getImage().flush().

The images I work with tend to get loaded when the program starts and
hang around till it terminates.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Jason Cavett - 05 Mar 2008 17:48 GMT
On Mar 5, 3:05 am, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Tue, 4 Mar 2008 11:40:35 -0800 (PST), Jason Cavett
> <jason.cav...@gmail.com> wrote, quoted or indirectly quoted someone
[quoted text clipped - 13 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

someObject is a TreeCellEditor.  I set the image on the TreeCellEditor
so I can set icons on the JTree.

What I was thinking is that I may not need to flush due to the fact
that, when the TreeCellEditor is destroyed, it'll lose the references
to the image (since no other references are held anywhere).


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.