[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: OutOfMemoryError on event-handling thread

Ed Merks wrote:
> Or, as suggested in the other post, you could allocate a bunch of
> storage up front as a reserve.  You might even release it so that your
> JVM could hobble along.

That's an excellent idea for situations where I can count on code to behave
well in the face of allocation failures.  However...

> something is likely to have failed miserably and might
> have left things in not a great state.

... all the code in the framework would have to be written to be robust
against OOMErrors, which is not a common or expected standard for Java
code.  I certainly never thought about it when writing Java until it became
an issue for my application.  I happen to have designed my code to be
robust against unexpected exceptions, but only because it includes a lot of
Python (Jython), which doesn't have checked exceptions :-)
  
> It
> suppose it's also possible to detect impending heap exhaustion, so you
> might produce a warning up earlier or avoid taken an action likely to
> exhaust the heap (editing a large data set)...

I think this is my best option in the short term.  Using Runtime.freeMemory
and a conservative estimate of the amount of memory needed to load and
display each dataset, I should be able to prevent heap allocation failures
from happening in the first place.

Ed, thank you for the comments and suggestions, and thanks also to Robert B.
for his responses.

-David