Re: Out-of-Memory Handling in Long-Running / Server Applications
Burt Beckwith <[email protected]> Sun, 13 Apr 2008 11:51:03 -0400
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
You can't really force GC - calling System.gc() is only a request for garbage collection. But you can use the MemoryMXBean as described in http://www.javaspecialists.eu/archive/Issue092.html to do the memory cleanup when you're approaching zero heap rather than when you're actually there. Burt On Sunday 13 April 2008 11:41:14 am Randall R Schulz wrote: > Hi, > > My application has highly variable running times and memory demands > based on the problems submitted to it. Some hard-to-solve (or > insoluble) problems will run it out of memory. > > 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. > The vast majority of the RAM is used in the search tree, which is > linked only upwardly from the leaves and the leaves are all in a > priority queue, so relinquishing the priority queue is enough to make > all the objects in the tree unreferenceable. > > This technique sometimes works and sometimes does not. I.e., when it > doesn't work the program gets another OOM very shortly after or during > the my OOM handling and dies. > > Until recently, this application was mostly run from the command line so > this behavior was not such a big problem. Now it's being used much more > in its Web-App form (running in Tomcat 5.5, at the moment), this > inadequate handling is becoming a problem. > > > What techniques are available for handling OOM errors in situations > where simply dying on the spot is not an option? > > > Thanks. > > Randall Schulz > > =================================== > This list is hosted by DevelopMentorĀ® http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com