[Solved-2 Solutions] Dealing with “java.lang.OutOfMemoryError: PermGen space” error



Error Description :

    • If you are getting an error in your web application:

    java.lang.OutOfMemoryError: PermGen space

    • It's a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6. Apparently this can occur after redeploying an application a few times.
    • What causes it and what can be done to avoid it? How to fix the problem?

    Solution 1 :

    • The solution was to add these flags to JVM command line when Tomcat is started:
    -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
    
    click below button to copy the code. By - Java tutorial - team
    • We can do that by shutting down the tomcat service, then going into the Tomcat/bin directory and running tomcat6w.exe. Under the "Java" tab, add the arguments to the "Java Options" box. Click "OK" and then restart the service.
    • If we get an error the specified service does not exist as an installed service you should run:
    tomcat6w //ES//servicename
    
    click below button to copy the code. By - Java tutorial - team
    • where servicename is the name of the server as viewed in services.msc

    Solution 2:

    • You better try -XX:MaxPermSize=128M rather than -XX:MaxPermGen=128M.
    • I can not tell the precise use of this memory pool, but it have to do with the number of classes loaded into the JVM. (Thus enabling class unloading for tomcat can resolve the problem.) If your applications generates and compiles classes on the run it is more likely to need a memory pool bigger than the default.

    Related Searches to Dealing with “java.lang.OutOfMemoryError: PermGen space” error