File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Is outOfMemory error always logged 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 » Java in General
Bookmark "Is outOfMemory error always logged" Watch "Is outOfMemory error always logged" New topic

Is outOfMemory error always logged

sarveswaran meenakshi sundaram

Joined: Nov 04, 2004
Posts: 6
Dear all,

Our Java application (uses SWing,net and other standard packages)suddenlty quits with out a trace. We are aware of the fact that we are facing OutOfMemory probelm. Does java guarantee that OutOfMemory error will always be logged? Or is it possible that the application will quit with out logging OutOfMemory error due to non-availablity of memory even for the log action?

Thanks in advance
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Your application is more likely to hang rather than exit with this exception.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
According to my experience, we cannot do anything when JVM raises OutOfMemory error.
The application will quit automatically and we can see the stacktrace about that error..

Correct me if I am wrong...
sarveswaran meenakshi sundaram

Joined: Nov 04, 2004
Posts: 6
hi all,

Thanks for the replies.

I'm getting in to the details. In our application, when ever an exception occurs, we capture it, open a file, log the exception in the file, then close the file. When OutOfMemory error occurs, is it guranteed that all the actions that I have specified here will occur so that the exception is logged in our exception file? Or is it possible that the application may quit with out logging the exception in the file due to the non availablity of memory for the set of we have follow to log exceptions in our file?
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
First, OutOfMemoryError is an Error, not an Exception. If you only catch Exception, you will not catch OutOfMemoryError.

Second, trying to respond to OutOfMemoryError is difficult. It can happen at any time, so your data structures may be broken. Also, if your attempt to handle OutOfMemoryError tries to allocate memory (e.g. write to a log file), then that may cause another OutOfMemoryError.

Third, various versions of the JVM have various bugs that mean that OutOfMemoryError does not always get thrown, when it ought to. Sometimes, the JVM crashes or exits instead.

Lastly, the JVM can run occasionally out of other memory-type resources than Java heap. This can cause various problems.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I agree. Here's the link:
subject: Is outOfMemory error always logged
It's not a secret anymore!