On Sunday 13 April 2008 13:08, Endre Stølsvik wrote:
> 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.
> 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.
One of the biggest weaknesses of the sorts of techniques that you and I
are using is that the OOM may be delivered to another thread (instead
of or in addition to being delivered to your own).
The technique presented in the article referred to by Burt B. looks good
to me, and I'm in the process of implementing it in my application now.