wood burning stoves
The moose likes Java in General and the fly likes Out of Memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Out of Memory" Watch "Out of Memory" New topic

Out of Memory

Geetha Gubendran
Ranch Hand

Joined: Sep 04, 2006
Posts: 75
I have a doubt. If there is a project which is developed using a pure core java. If that project is running in production but throws out of memory error. How will that error be fixed? Can somebody help me with this?
Marco Ehrentreich
best scout

Joined: Mar 07, 2007
Posts: 1294

Hi Raj,

if there's enough physical memory in your machine you can simply start Java with additional parameters to increase the memory available to the JVM.

Java -X will give you an overview for more parameters.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46326
. . . and make sure you don't have some sort of collection gradually collecting object references which ought to have beet assigned to null, or anything like that.
arulk pillai
Ranch Hand

Joined: May 31, 2007
Posts: 3371
In Java, typically memory leak occurs when an object of a longer lifecycle has a reference to objects of a short life cycle. This prevents the objects with short life cycle being garbage collected. The developer must remember to remove the references to the short-lived objects from the long-lived objects. Objects with the same life cycle do not cause any issues because the garbage collector is smart enough to deal with the circular references

-- Use tools like JProbe, OptimizeIt etc to detect memory leaks.

-- Use operating system process monitors like task manager on NT systems, ps, vmstat, iostat, netstat etc on UNIX systems.

-- Write your own utility class with the help of totalMemory() and freeMemory() methods in the Java Runtime class. Place these calls in your code strategically for pre and post memory recording where you suspect to be causing memory leaks. An even better approach than a utility class is using dynamic proxies (Refer Q11 in How would you go about section´┐Ż) or Aspect Oriented Programming (AOP) for pre and post memory recording where you have the control of activating memory measurement only when needed.
[ June 02, 2008: Message edited by: arulk pillai ]

[Java-Success.com] | [Java job hunting know how] | [Java resumes]
I agree. Here's the link: http://aspose.com/file-tools
subject: Out of Memory
It's not a secret anymore!