powered by Jive Software

Server Hang with "Java heap space"

Dear All

I build openfire server with spec :

Windows Server 2008 standard 64 bit

2 CPU 2.4 Ghz

Memory 4 GB

Install openfire to D:\openfire

Detail of openfire

Install plugin : Monitor Service and Search

User remain : 5000 account with LDAP

Concurent : not over 25

Client Connection remain : 60

Traffic before hang : 225 kb per minute

Packet count before hang : 150

Created openfire-service.vmoptions to D:\openfire\bin and push -Xms512m -Xmx1024m to this file

When start server i found Java scale to 99% and if boardcast massage to all user server was hang with “Java heap space” in below.

When restart, server still hang with message **“Java heap space” **must restart many time to ok but java scale still high to 99%.

Please Help me solve this problem.

2014.02.12 16:48:59 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

at com.jcraft.jzlib.Deflate.deflateInit2(Deflate.java:1369)

at com.jcraft.jzlib.Deflate.deflateInit(Deflate.java:1316)

at com.jcraft.jzlib.ZStream.deflateInit(ZStream.java:127)

at com.jcraft.jzlib.ZStream.deflateInit(ZStream.java:123)

at com.jcraft.jzlib.ZStream.deflateInit(ZStream.java:117)

at org.apache.mina.filter.support.Zlib.(Zlib.java:79)

at org.apache.mina.filter.CompressionFilter.onPreAdd(CompressionFilter.java:209)

at org.apache.mina.common.support.AbstractIoFilterChain.register(AbstractIoFilterC hain.java:156)

at org.apache.mina.common.support.AbstractIoFilterChain.addAfter(AbstractIoFilterC hain.java:134)

at org.jivesoftware.openfire.nio.NIOConnection.addCompression(NIOConnection.java:3 81)

at org.jivesoftware.openfire.net.StanzaHandler.compressClient(StanzaHandler.java:5 10)

at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:187)

at org.jivesoftware.openfire.nio.ConnectionHandler.messageReceived(ConnectionHandl er.java:169)

at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived (AbstractIoFilterChain.java:570)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)

at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)

at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)

at org.apache.mina.common.IoFilterAdapter.messageReceived(IoFilterAdapter.java:80)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)

at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)

at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)

at org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flush(SimplePr otocolDecoderOutput.java:58)

at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecF ilter.java:185)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)

at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)

at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)

at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java :239)

at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(Execut orFilter.java:283)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)

at java.lang.Thread.run(Unknown Source)

2014.02.12 16:49:34 org.jivesoftware.openfire.interceptor.InterceptorManager - Error in interceptor: org.jivesoftware.openfire.archive.ArchiveInterceptor@935862 while intercepting:

Try to remove monitor service.

Pitak, this is a common case when using openfire in some cases. I run my xmpp service on windows machines as well and sometimes get and java heap space error while some plugin/process gone wild.

Sadly, java has a poor garbage collection… Anyway try to allocate more ram to the java heap size, like -Xms768m -Xmx1536m. (Or maybe even more if you have to use the monitor service).

The problem is, the things in memory are not available for garbage collection since they are objects in use (ie. there’s a reference to them). I do agree increasing the jvm memory settings may help.

Just note, that for a server supporting 5000 users, and running Windows 2008, 4GB of physical host ram is probably not enough. Windows may consume 1-2GB just idling, any other services running will eat into that as well. If you allocate 1.5GB to the jvm, then this leaves very little room for anything else to happen on your server, including normal windows background tasks that can momentarily bloat ram usage. This is assuming of course your server is doing nothing else but being an Openfire server… if it’s doing anythiing else such as DNS server, AD server, etc, then this issue worsens greatly. You could potentially starve out your entire server.

1 Like

Thanks for reply. I have some question.

  • Now we are using embeded HSQLDB. If we change to use mysql db instead, will we not get jvm memory full problem?

  • we have already increased java mem to 2 GB but Open Fire still can’t be opened.

So if we increase Physical Mem of Windowsl then we can also increase java memory, is it right?

  • Now we are using embeded HSQLDB. If we change to use mysql db instead, will we not get jvm memory full problem?

Definitely you should use some external database like MySQL for such userbase. Embedded database is stored in the memory when Openfire is running, so it has some impact on the memory consumption.