HI,
has anyone seen this? I have a multithreaded app, using Postgres JDBC
running on Solaris - Java HotSpot(TM) 64-Bit Server VM (build
1.5.0_05-b05, mixed mode). Randomly, I get the
j"ava.lang.OutOfMemoryError: Java heap space". But Checking it,
Runtime.freeMemory, JConsole and YourKit all say that The heap is using
200Mb when -Xmx is 400Mb. The machine has 1 Gb of RAM, and should
easily be able to malloc more memory for the VM.
Does anybody have any clues? This is really confusing me.
Thanks in advance.
James.
Ben_ - 25 Apr 2006 17:10 GMT
Hello,
Fragmented heap can be a cause: there are many spaces of heap available and
the sum of them makes you think that there is plenty of free mem (which is
the case), but there is not enough contiguous memory to allocate a large
object.
So, for example, you may very well be able to allocate 10 String objects of
1 MB, but cannot allocate a single 3 MB String object.
There is a good discussion of this in IBM JVM Diagnostic Guide
(www.ibm.com/developerworks/java/jdk/diagnosis). It's IBM implementation,
but it's interesting as it's very much detailed.
Thomas Hawtin - 26 Apr 2006 15:30 GMT
> has anyone seen this? I have a multithreaded app, using Postgres JDBC
> running on Solaris - Java HotSpot(TM) 64-Bit Server VM (build
[quoted text clipped - 3 lines]
> 200Mb when -Xmx is 400Mb. The machine has 1 Gb of RAM, and should
> easily be able to malloc more memory for the VM.
It is possible that somewhere is attempting to allocate more than 200 MB
at once. Also there have been problems with the permanent generation
(class files, compiled code and interned strings) not being fully
garbage collected before the OOME is thrown (fixed in very recent 1.6
builds, apparently). Mainly a GUI problem, but sometimes OOME can be
thrown due to running out of some other resource, such as GDI space on
Windows.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/