Re: Out-of-Memory Handling in Long-Running / Server Applications

Endre Stølsvik <[email protected]> Sun, 13 Apr 2008 22:08:23 +0200
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
Randall R Schulz wrote:
> Hi,
>
> When memory is exhausted in the inner loop of the program (the only
> place it's going to happen), I catch the OutOfMemoryError, release the
> storage, trigger a GC (forcing it would seem desirable, but I'm not
> sure how to do that) and report the failure back up the call chain.

Interesting.

I have a rather similar problem, where I allocate sometimes huge
BufferedImages (thus, large int arrays). However, due to a "memory
landlord" thing I have going, I know there shall be enough memory. Also,
sometimes, if dumping the Runtime.*Memory() thingies, I see that the JVM
agrees that there actually are enough memory, but I get a OOM anyway (I
guess the free areas are fragmented..). I then System.gc() and actually
loop till it works out, and this always seem to work just fine.

However, I'm a bit sceptical to this, since I believe I've read that
after a OOM, you'd better throw away the entire JVM, since it'll be
unstable and generally not feeling all that good - and you might get any
kind of problems later on.
   Anyone have any information (pointers) about this?

Endre.

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com