Out of Memory: Java heap space (solved)

2,283 views
Skip to first unread message

Neil Gordon

unread,
Oct 16, 2014, 4:09:56 AM10/16/14
to idem...@googlegroups.com
Out of Memory: Java heap space (solved)

We want to share this problem and solution with the community, in case anyone else runs into a similar problem.

Our server (in production, and under load) would run out of heap memory with an error: 

Exception in thread "http-bio-8088-exec-23" java.lang.OutOfMemoryError: Java heap space
at org.apache.tomcat.util.buf.ByteChunk.allocate(ByteChunk.java:163)
at org.apache.tomcat.util.buf.ByteChunk.<init>(ByteChunk.java:128)
at org.apache.catalina.connector.OutputBuffer.<init>(OutputBuffer.java:157)
at org.apache.catalina.connector.OutputBuffer.<init>(OutputBuffer.java:145)
at org.apache.catalina.connector.Response.setConnector(Response.java:148)
at org.apache.catalina.connector.Connector.createResponse(Connector.java:844)

The solution was pointed to by this bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1051245

Since we have upgraded to Oracle JDK 1.6.0_45, the problem has not occurred again within a period of a month. 

Previously, we experienced the problem every 3 to 7 days.

We have marked the problem as solved. The heap usage on the iDempiere Server Monitor seems to be much improved.

We continue to monitor memory usage on the server.

The JDK previously in use was: 

OpenJDK, java version "1.6.0_30"
OpenJDK Runtime Environment (IcedTea6 1.13.1) (6b30-1.13.1-1ubuntu2~0.12.04.1)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

The problem may have also been solved by using the latest OpenJDK, but this was not tested.
 
 -----
Neil Gordon
nTier Software Services
 
 

Neil Gordon

unread,
Oct 16, 2014, 10:04:20 AM10/16/14
to idem...@googlegroups.com

Dirk Niemeyer

unread,
Nov 28, 2014, 8:58:45 AM11/28/14
to idem...@googlegroups.com
I was running iDempiere2.0 on OpenJDK 1.7u51 and after uprading to
iDempiere2.1 I had also a heap space problem.

Upgrading OpenJDK to 1.7u65 did not help.

I then found some info titled
"Tomcat configuration: Memory - Heap and PermGen"
at
https://developer.opentext.com/webaccess/#url=%2Fawd%2Fresources%2Farticles%2F6123%2Ftomcat%2Bconfiguration%2Bmemory%2B%2Bheap%2Band%2Bpermgen

It says:

"For errors pertaining to “heap”, we will be tweaking the “-Xmx” setting.

Some notes on this now…

The default heap size is typically 64MB.
This setting is of the form -Xmx(memorysize). i.e. -Xmx2048m sets
the max heap size to 2048 megabytes.
32 bit JVM is limited to approximately 1.8GB on Windows and 2GB on
Linux.
Performance recommendation is to set the initial heap size equal
(-Xms) to the max heap size."

I have now just added "-Xms1024m -Xmx1024m" to the last line in
idempiere-server.sh and for me the problem is gone.

Regards,

Dirk Niemeyer

Neil Gordon

unread,
Dec 2, 2014, 3:46:13 AM12/2/14
to idem...@googlegroups.com
Thanks Dirk, very useful information indeed.

Another thing is to set Hazelcast configuration as standalone. I've seen similar errors (for some reason) when running using Hazelcast with Multicast enabled.

To do this, see:


Another thing, is when running in Eclipse, to remember to use the server.product.eventtest configuration, instead of  server.product. "server.product" runs with Hazelcast enabled, and I experienced similar out of memory errors, on r21, when using this configuration.


-----
Neil Gordon
nTier Software Services

Victor Suárez

unread,
Dec 2, 2014, 2:16:20 PM12/2/14
to idem...@googlegroups.com
Hi Neil.

Thanks for your input, it can sometimes also be the "Java Runtime Options" parameter in the configuration file "idempiereEnv.properties"
#Java Runtime options
IDEMPIERE_JAVA_OPTIONS = -Xms64M -Xmx512M.
There you can change the defaults of RAM, minimum and maximum.

Regards.
Reply all
Reply to author
Forward
0 new messages