Michael Paesold wrote:
> Dave Cramer <Dave@micro-automation.net> wrote:
>
>
>>Should the gc run before an OutOfMemoryException is thrown
>>
>>in other words are the jvm's smart enough to run the gc if they are out
>>of memory?
>
>
> Yes, the jvm should be smart enough to regain unused memory before throwing
> an OutOfMemoryException. The global gc runs in the backround in defined
> intervals, but more often in low memory situations, as far as I know.
From the documentation of the OutOfMemoryError:
"Thrown when the Java Virtual Machine cannot allocate an object because
it is out of memory, and no more memory could be made available by the
garbage collector. "
Thus, the VM tries to get the memory needed through a garbage collection
before it gives up and throws an error.
<snip>
> Does the overall memory consumption increase, even with System.gc() called
> explicitly? Have you tried running it until the jvm needs more than maximum
> allowed memory? (the limit can be set with command line arguments)
Also, add the flag -verbose:gc to java to see the actual garbage
collection taking place. If you combine that with adding a System.gc()
you'll probably end up with enough debug info.
--
_/ _/_/_/ _/ _/ _/_/_/ | Jens Carlberg
_/ _/ _/_/ _/ _/ | jenca@lysator.liu.se
_/ _/_/ _/ _/_/ _/ | +46 13 260872
_/_/ _/_/_/ _/ _/ _/_/_/ | ICQ: 44194995