The documentation for OutOfMemoryError seems to imply that garbage collection will be run before the JVM gives up and throws OutOfMemoryErrors:
Your message doesn't make it clear if you are getting OutOfMemoryErrors or java.exe is crashing due to exhausting all the physical and virtual memory the OS has available. If you are getting OutOfMemoryErrors you definately have a memory leak. If java.exe is crashing try fiddling around with the maximum amount of memory the JVM can request from the OS. I believe that there is some sort of -X flag for setting it.
When the application crashes, the errors that I get are not always the same. In some cases, I see something like:
Exception java.lang.OutOfMemoryError: requested 16 bytes for CHeapObj-new. Out of swap space?
This error is described in:
I believe it is caused by all the instances of my application growing so large â€“ Solaris is just running out of system resources. So, based on the input I have received and further investigation, I believe the root cause is a memory leak. We are now trying TPTP to isolate it. Of course, we could also try tweaking some of the JVM parameters, so that the â€œMark Sweepâ€ GC is invoked more frequently. But this seems like a â€œbandaidâ€ solution.
Thanks for the pointers,
as you figured, a sane Java application should not call System.gc() or System.runFinalization() except for very, very special cases - the only one I can think of is to release OS resources in a finalizer if a client has forgot to explicitly "close" the resource.
From what you're saying, it sounds your app is suffering from a memory leak. Instead of messing with the garbage collector, I'ld recommend to fix it. I use jhat/jmap that comes with any recent JDK to do this. Quite effective, although the UI could be advanced (NetBeans?).
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.