Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is outOfMemory error always logged

 
sarveswaran meenakshi sundaram
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your application is more likely to hang rather than exit with this exception.
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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...
daniel
 
sarveswaran meenakshi sundaram
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic