<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Danfo Yam

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      5 Posts :: 1 Stories :: 6 Comments :: 0 Trackbacks

    Classloader leaks and PermGen space

    After googling a bit for error “java.lang.OutOfMemoryError: PermGen space” I found many sites talking about that problem. Some tried passing command line arguments to the JVM or changing the size of the PermGen space, others end up recommending using a VM from BEA or IBM, all without success.

    But after a closer look at their comments I ended up at Frank Kieviet blog.
    Frank explains what really is a PermGen error

    The problem in a nutshell

    Application servers such as Glassfish allow you to write an application (.ear, .war, etc) and deploy this application with other applications on this application server. Should you feel the need to make a change to your application, you can simply make the change in your source code, compile the source, and redeploy the application without affecting the other still running applications in the application server: you don’t need to restart the application server. This mechanism works fine on Glassfish and other application servers (e.g. Java CAPS Integration Server).

    The way that this works is that each application is loaded using its own Classloader. Simply put, a Classloader is a special class that loads .class files from jar files. When you undeploy the application, the Classloader is discarded and it and all the classes that it loaded, should be garbage collected sooner or later.

    Somehow, something may hold on to the Classloader however, and prevent it from being garbage collected. And that’s what’s causing the java.lang.OutOfMemoryError: PermGen space exception.

    PermGen space

    What is PermGen space anyways? The memory in the Virtual Machine is divided into a number of regions. One of these regions is PermGen. It’s an area of memory that is used to (among other things) load class files. The size of this memory region is fixed, i.e. it does not change when the VM is running. You can specify the size of this region with a commandline switch: -XX:MaxPermSize. The default is 64 Mb on the Sun VMs.

    If there’s a problem with garbage collecting classes and if you keep loading new classes, the VM will run out of space in that memory region, even if there’s plenty of memory available on the heap. Setting the -Xmx parameter will not help: this parameter only specifies the size of the total heap and does not affect the size of the PermGen region.

    … and how to use new profiling tools in Java 6 to fix Classloader leaks.
    Resuming, the steps are:

    1. start your application server
    2. deploy and run your application
    3. undeploy the application that is leaking (just the application not the server)
    4. trigger a memory dump jmap -dump:format=b,file=leak <PID>
    5. run jhat (with modification, Java SE SDK 6.0 update 1 has the updated code) jhat -J-Xmx512m leak
    6. go to jhat report http://localhost:7000/ (http://localhost:7000/oql/ if you need the OQL (Object Query Language))
    7. find a leaked class (any class of your application since you shouldn’t see any objects of the classes that you deployed)
    8. locate the Classloader
    9. find the “Reference chains from root set”
    10. inspect the chains, locate the accidental reference, and fix the code

    Some try even to go further on finding Orphaned Classloaders others try to nicely present the leaking classes in a form of a HTML table histogram.

    These tools can really help, use them!

    轉載自:http://www.samaxes.com/2007/10/classloader-leaks-and-permgen-space/
    posted on 2010-05-26 23:26 Danfo Yam 閱讀(467) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 98精品全国免费观看视频| 午夜国产精品免费观看| 中国内地毛片免费高清| 日本h在线精品免费观看| 国产国产人免费人成免费视频| 亚洲av午夜福利精品一区| 亚洲AV无码专区在线电影成人 | 国产亚洲?V无码?V男人的天堂| 亚洲春色在线观看| 中国一级特黄高清免费的大片中国一级黄色片 | 99re免费在线视频| 亚洲视频在线观看免费| 国产成人亚洲精品电影| 巨波霸乳在线永久免费视频| 国产成人亚洲综合| 亚洲精华国产精华精华液| 无码av免费网站| 亚洲一区二区女搞男| 久久亚洲精品11p| 亚洲精品WWW久久久久久| 亚洲精品色播一区二区| 国产成人免费一区二区三区| 免费很黄无遮挡的视频毛片| 四虎www成人影院免费观看| 亚洲国产日韩在线| 久久久久久久岛国免费播放| 亚洲白嫩在线观看| 久久久久久影院久久久久免费精品国产小说 | 中文字幕精品亚洲无线码一区| 亚洲日韩久久综合中文字幕| 18女人水真多免费高清毛片| 亚洲中文字幕精品久久| 国产a视频精品免费观看| 亚洲国产精品无码中文lv| 亚洲欧洲一区二区三区| 99久9在线|免费| 黄网站色成年片大免费高清| 国产成人免费永久播放视频平台 | 99视频在线看观免费| 亚洲色偷偷综合亚洲AV伊人蜜桃 | 亚洲国产成人久久三区|