我用openfire做爲 IM服務器,項目測試時發現基本每過大約1天的時間就會產生內存溢出,導致用戶登錄不上去,內存溢出時,會在D:\Openfire\logs\生成一個日誌文件stderr.log,內容是:
Exception in thread "Thread-5" java.lang.OutOfMemoryError: Java heap space
at javax.swing.text.GapContent.allocateArray(Unknown Source)
at javax.swing.text.GapVector.resize(Unknown Source)
at javax.swing.text.GapVector.shiftEnd(Unknown Source)
at javax.swing.text.GapContent.shiftEnd(Unknown Source)
at javax.swing.text.GapVector.open(Unknown Source)
at javax.swing.text.GapVector.replace(Unknown Source)
at javax.swing.text.GapContent.insertString(Unknown Source)
at javax.swing.text.AbstractDocument.handleInsertString(Unknown Source)
at javax.swing.text.AbstractDocument.insertString(Unknown Source)
at org.jivesoftware.openfire.launcher.Launcher$5.construct(Launcher.java:437)
at org.jivesoftware.openfire.launcher.SwingWorker$2.run(SwingWorker.java:134)
at java.lang.Thread.run(Unknown Source)
我配置內存的方式:
D:\Openfire\bin目錄下增加一個openfired.vmoptions文件,用來配置 JVM參數:
-Xms1024m
-Xmx1256m
-XX:SurvivorRatio=7
-XX:PermSize=256m
-XX:MaxPermSize=256m
指定了最大內存1256M,其中永久內存256M ,在控制檯中看到openfire可用內存確實變大了,但是仍然解決不了大約每天內存溢出一次,哪位高人指點一下迷津?