What can be done with 'PermGen out of space' exception in Tomcat-Spring-Hibernate web application?

前端 未结 8 868
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 05:12

We have an web application that uses Spring-Hibernate to persist registered users data in Oracle database. The application works fine in development environment, but when we

相关标签:
8条回答
  • 2020-12-05 05:32

    As skaffman says the -XX:MaxPermSize property does work, however sometimes you can have an underlying problem that upping the limit may only defer.

    Have you seen this note? It helped me resolve a similar problem once. To summarise the link:

    • Put JDBC driver in common/lib (as tomcat documentation says) and not in WEB-INF/lib
    • Don't put commons-logging into WEB-INF/lib since tomcat already bootstraps it
    0 讨论(0)
  • 2020-12-05 05:42

    Visual GC, now part of JDK 6, gives a very nice graphical representation of memory in real time. You can see what's happening to eden, generational, and perm spaces. You just won't see why.

    UPDATE: It's bin/jvisualvm.exe in my JDK 1.6.0_13 distro. Give it the PID of the process you want to monitor.

    0 讨论(0)
  • 2020-12-05 05:45

    I ran in the same problem, and I've read that Tomcat is the culprit in this situation.

    Then I switched to jetty instead and everything turned out great, and the app deploys/runs as expected. So if tomcat is not a must, then I'd suggest Jetty.

    0 讨论(0)
  • 2020-12-05 05:48

    You must be aware that some versions of Tomcat have memory leaks on war redeployment. It happened to me on tomcat 6.0.x.

    As suggested increase the MaxPermSize, this is a temporary solution for your development machine - and when you get the error, after 2-3 days, just restart the server. On production is not that simple. So this works for development, but this approach doesn't work for production, where you should have the memory leaks issues fixed.

    To discover the leaks use the jconsole application that comes with jdk 1.6 and 1.5. You can bind to a process, and watch memory used over time.

    You can also read these:

    • http://frankkieviet.blogspot.com/2006/10/classloader-leaks-dreaded-permgen-space.html
    • http://frankkieviet.blogspot.com/2006/10/how-to-fix-dreaded-permgen-space.html
    • http://java.sun.com/developer/technicalArticles/J2SE/monitoring/index.html
    • http://my.opera.com/karmazilla/blog/2007/03/13/good-riddance-permgen-outofmemoryerror
    • http://my.opera.com/karmazilla/blog/2007/03/15/permgen-strikes-back
    0 讨论(0)
  • 2020-12-05 05:49

    I have seen this problem with Hibernate (used without Spring). The issue there was that we were creating an instance of a SessionFactory for each user request rather than creating a single instance for the lifetime of the application.

    I used the YourKit profiler to investigate this and discover the issue.

    0 讨论(0)
  • 2020-12-05 05:51

    If you're running on jdk6 then you can use the jconsole app to monitor the memory usage of the application and investigate further.

    Another avenue to pursue is to use a profiler, I use JProfiler, and take a look at the application with that. It will tell you exactly where the problem is coming from.

    0 讨论(0)
提交回复
热议问题