2

I'm trying to run several tools on a Windows Tomcat server . The server starts fine, and I can also see the manager page of Tomcat. But when I open a tool, an "OutOfMemoryError: PermGen space" occurs. I tried a lot with setting the MaxPermSize in my catalina.bat, this is my CATALINA_OPTS:

set CATALINA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms64m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"

When I run JVisualVM next to my Tomcat server, I can see that the arguments are picked up well: overview

But when I go to the monitor tab and check the PermGen, the max is 67mb instead of the 512 that I set my CATALINA_OPTS. So the arguments are set, but Tomcat ignores them.. permgen

I tried fixing this problem for a couple of hours already, but without success..

Anyone?

harmjanr
  • 930
  • 2
  • 11
  • 27

1 Answers1

5

Remove the "" in the set and you are fine... Don't know why, yet. But that's the answer

set CATALINA_OPTS=-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms64m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

-- edit

Btw, I think you want the UseConcMarkSweepGC as well, otherwise the other 2 CMS parameters won't do a thing (and one of the 2 is only needed, depening on the version of the JVM)

See What does JVM flag CMSClassUnloadingEnabled actually do?

-- edit 2

This question was also asked for tomcat6 here: https://serverfault.com/questions/64894/setting-catalina-opts-for-tomcat6-on-windows-doesnt-work

Too bad the blogger doesn't explain why you don't need to use quotes in windows.

http://javahowto.blogspot.nl/2006/06/6-common-errors-in-setting-java-heap.html

But I think it's because with the quotes it's seen as one big argument. The only thing that I don't understand is why the jvisualvm pretends you set it correctly. But I guess the display of the arguments doesn't actually look at how it's set in the JVM, but only formats the arguments nicely.

Community
  • 1
  • 1
DelGurth
  • 869
  • 6
  • 10
  • When I try that and run startup.bat, the tomcat server window immediately closes. I can't read any error that occures on the server, since it closes too fast. And yes, I start the server from command prompt. But the MaxPermGen attribute is shown in the JVisualVM with the "", so it seems that the CATALINA_OPTS is fine.. – harmjanr Dec 14 '12 at 10:29
  • @harmjanr: that's how I got it to work, and yes it seems it's fine, but you see in the jvisualvm that you are using the client version and none of your modifications work... Perhaps it's the place in the script where you set the CATALINA_OPTS as well? Not sure, the problem is really vague. I put it just before Execute The Requested Command: set CATALINA_OPTS=-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms64m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled rem ----- Execute The Requested Command --------------------- – DelGurth Dec 14 '12 at 10:33
  • 1
    I managed to get the error visible, and this was the error: "error no server jvm at jre/bin/jvm.dll". So I copied the server dir from the java JDK to the java JRE dir. Now the server started without the quotes around the CATALINA_OPTS, AND I have a permgen of 512m. Thanks! – harmjanr Dec 14 '12 at 10:41
  • Good to hear that. And yeah, getting that error visible is not easy, at least I didn't find the option for that easily. – DelGurth Dec 14 '12 at 10:53
  • I changed the last rule of the startup.bat, so the tomcat server doesn't start in a new window: call "%EXECUTABLE%" start %CMD_LINE_ARGS% to: call "%EXECUTABLE%" run %CMD_LINE_ARGS% – harmjanr Dec 14 '12 at 10:57