java.lang.OutOfMemoryError: Java heap space

This bug has bitten me twice in the last month. Any idea what could be causing this? Wowza Media Server 3.0.3.08 build959 on EC2, Amazon Linux AMI release 2011.09, small instance.

2012-06-23 01:36:31 UTC - - - - - - - - - 2.292 - - - - - - - - - - - - - - - - - - - - - - - - -java.lang.OutOfMemoryError: Java heap space

at java.nio.HeapByteBuffer.(HeapByteBuffer.java:57)

at java.nio.ByteBuffer.allocate(ByteBuffer.java:329)

at org.apache.mina.common.SimpleByteBufferAllocator.allocate(Unknown Source)

at org.apache.mina.common.ByteBuffer.allocate(Unknown Source)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.read(Unknown Source)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.process(Unknown Source)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$600(Unknown Source)

at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(Unknown Source)

at org.apache.mina.util.NamePreservingRunnable.run(Unknown Source)

at java.lang.Thread.run(Thread.java:636)

My setenv.sh contains:

_EXECJAVA=java

JAVA_OPTS="-Xmx1000M -server"

WMSAPP_HOME=/usr/local/WowzaMediaServer

WMSCONFIG_HOME=/usr/local/WowzaMediaServer

WMSCONFIG_URL=

VARJAVAMAXHEAPSIZE=1000M

GCOPTIONS="-XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:NewSize=128m -verbose:gc -Xloggc:"/usr/local/WowzaMediaServer/logs/gc.log" -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC"

export WMSAPP_HOME WMSCONFIG_HOME JAVA_OPTS _EXECJAVA GCOPTIONS VARJAVAMAXHEAPSIZE

Are setting java heap size to 1000m because you have limited ram and/or a 32bit system? That is not very high for a production server. I suggest getting a 64bit server with 4 - 8 gigs of ram, then setting java heap size accordingly.

Also, as noted in the tuning guide, avoid these custom GC options by default. Review step #6 in the tuning guide.

Richard