0

PermGen - Memory leak

asked 2009-01-12 06:25:36 +0800

lilithfr gravatar image lilithfr
3 1

Hello,

I have a memory leak issue when I deploy/undeploy my servlet.
I check with Jprofiler to detect where that come from.

To reproduce the issue very easly, I use a minimal web.xml and zk.xml, in the file web.xml there are only HttpSessionListener and DHtmlLayoutServlet, and the zk.xml file is empty.

After stopping my servlet, I saw lot of objects in memory from org.zkos.*, the classes HttpSessionListener and DHtmlLayoutServlet are correctly destroyed.
If I do that several time, I receive a permgen out of memory.

Is there another class to use to destroy the objects ?

delete flag offensive retag edit

12 Replies

Sort by ยป oldest newest

answered 2009-01-12 07:54:16 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

can you provide your environment info ?
like zk version ,the class & package name ?

link publish delete flag offensive edit

answered 2009-01-12 16:33:22 +0800

atxmaniek gravatar image atxmaniek
82 1 3

updated 2009-01-12 16:33:59 +0800

I have the same in Eclipse but it is caused by multiple project building without server restart (it appears if after i save project file few times eclipse build project itself without restarting server). So when im saving changes i restart server manually

link publish delete flag offensive edit

answered 2009-01-12 16:55:43 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

updated 2009-01-12 17:02:36 +0800

PermGen-Errors on "redeploy without restart" are quite common, so I don't think that this is a ZK-"issue":

http://www.jroller.com/agileanswers/entry/preventing_java_s_java_lang

Best workaround seems to be to start Tomcat with higher PermGen-Space:

java ... -XX:MaxPermSize=256m

Update:

Here's another good hint... enable GC for Perm-Space (which is disabled by default and the root cause of these kind of errors):

http://community.eapps.com/showthread.php?p=326

Cheers, Maik

link publish delete flag offensive edit

answered 2009-01-13 15:29:45 +0800

dastultz gravatar image dastultz
797 9

I haven't had time to bring this up myself... I agree that "PermGen-Errors on "redeploy without restart" are quite common" however I suspect that Zk contributes to the problem. They occur much more in my Zk app than non-Zk apps, and occur more when Zk jars in WEB-INF/lib vs Tomcat/lib. I think Zk loads lots if not all classes as part of startup configuration. I hit PermGen limit once and saw a bunch of messages about not being able to load classes referenced by lang-addon or whatever. Sorry, I'm in a hurry.

/Daryl

link publish delete flag offensive edit

answered 2009-01-14 02:08:10 +0800

iantsai gravatar image iantsai
2755 1

updated 2009-01-14 02:09:46 +0800

Because Java Classloader "WONT" release loaded classes, So hot deploy mechanism will consume your heap space every time it triggered.
(In SUN's JVM it surely cant release as I know, or can some one point out that I am wrong?)


I got the same configuration with mjablonski's post and this problem never bother me any more.


PS: DDR2 is too CHEAP, I could buy 2G in less then 16 USD which means it could be cheaper then my lunch!
What can I Say? God bless DRAM factories.

link publish delete flag offensive edit

answered 2009-01-16 15:04:53 +0800

dastultz gravatar image dastultz
797 9

updated 2009-01-16 15:05:25 +0800

I've been using the PermGen GC settings specified above for a day or so now. It seems to delay the out of memory problem, but not by much. My catalina.sh has these lines:

CATALINA_OPTS="-Xms128m -Xmx768m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n -XX:+CMSPermGenSweepingEnabled -XX
:+CMSClassUnloadingEnabled"
JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4000 -Dcom.sun.management.jmxremote.authenticate=false -Dco
m.\
sun.management.jmxremote.ssl=false"

Should the PermGen GC settings be CATALINA_OPTS or JAVA_OPTS? I don't think it really matters. Anyway, here's what I just got upon redeploy:
WARNING: Component label ignored. Reason: unable to load org.zkoss.zul.Label due to java.lang.OutOfMemoryError: PermGen space
[SYS jar:file:/Users/daryl/blah/blah/webapp/WEB-INF/lib/zul.jar!/metainfo/zk/lang.xml line 453 col 13]

I think this shows pretty clearly that Zk is loading classes before they are being used which seems like bad etiquette to me.

/Daryl

link publish delete flag offensive edit

answered 2009-01-17 03:38:06 +0800

iantsai gravatar image iantsai
2755 1

updated 2009-01-17 03:39:25 +0800

I don't see your permgen maximum setting in your CATALINA_OPTS, in SUN's JVM it should be looked like this:

-XX:MaxPermSize=200m

As I remembered, the default value is poorly low comparing how large RAM we have.

link publish delete flag offensive edit

answered 2009-01-19 15:02:36 +0800

dastultz gravatar image dastultz
797 9

I have it set on my production system but not my dev machine. I'll try it on my dev and see if it makes a difference.

/Daryl

link publish delete flag offensive edit

answered 2009-01-26 13:11:02 +0800

mixgho gravatar image mixgho
193 3

I have the same problem on JBoss. after (I'd say) 5-10 redeploys, PermGen error occurs. I set MaxPermSize to 256m but with no difference. I've never had this kind of a problem with other frameworks...

link publish delete flag offensive edit

answered 2009-01-26 14:43:20 +0800

dastultz gravatar image dastultz
797 9

>I don't see your permgen maximum setting in your CATALINA_OPTS, in SUN's JVM it should be >looked like this:

-XX:MaxPermSize=200m

>As I remembered, the default value is poorly low comparing how large RAM we have.

Ok, I've set my MaxPermGen to 256m and it seems to be fine. No more permgen errors on my development machine. I guess it needed a little breathing room to do GC on PermGen. Next is the production configuration...

So my development settings are now:

CATALINA_OPTS="-Xms128m -Xmx768m -XX:MaxPermSize=256m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n"
JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.\
sun.management.jmxremote.ssl=false -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled"

/Daryl

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-01-12 06:25:36 +0800

Seen: 1,830 times

Last updated: Feb 02 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More