<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 閱讀(461) 評論(0)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: 亚洲精品午夜在线观看| 国产亚洲美女精品久久久| 亚洲最大黄色网址| 精品在线免费观看| 亚洲视频在线观看一区| 99久久久国产精品免费牛牛四川| 亚洲AV日韩AV永久无码久久 | 无码专区一va亚洲v专区在线| 国产亚洲视频在线观看| 波多野结衣一区二区免费视频| 风间由美在线亚洲一区| 亚洲av无码国产精品色在线看不卡| 特级毛片A级毛片100免费播放 | 亚洲av无码成h人动漫无遮挡| 69av免费观看| 亚洲综合一区国产精品| av无码东京热亚洲男人的天堂| 国产精品免费久久久久影院| 亚洲熟妇无码八AV在线播放| 99爱视频99爱在线观看免费| 亚洲av乱码一区二区三区 | 四虎成人免费网址在线| 美女羞羞免费视频网站| 中文字幕亚洲无线码| 午夜视频在线免费观看| 亚洲一卡2卡3卡4卡5卡6卡| 亚洲国产成人a精品不卡在线| 国产性生大片免费观看性 | 亚洲激情视频网站| 免费h黄肉动漫在线观看| 日批视频网址免费观看| 亚洲午夜福利在线视频| 狠狠亚洲婷婷综合色香五月排名| 3344免费播放观看视频| 国产精品亚洲综合| 久久精品国产亚洲AV电影| 国产网站免费观看| 黄页免费在线观看| 国产精品亚洲一区二区三区久久 | 一级毛片**不卡免费播| 老子影院午夜伦不卡亚洲|