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

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

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

    Danfo Yam

      BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
      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!

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

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 久久亚洲精品视频| 亚洲人成无码网站在线观看| 97免费人妻无码视频| 18禁亚洲深夜福利人口| 亚洲中文字幕无码久久精品1| 7x7x7x免费在线观看| 亚洲精品色在线网站| 亚洲成AV人片一区二区| 天天干在线免费视频| 丝袜捆绑调教视频免费区| 亚洲一级大黄大色毛片| 久久亚洲AV无码西西人体| 在线观看成人免费视频不卡| 丰满人妻一区二区三区免费视频| 亚洲精品福利你懂| 亚洲性猛交XXXX| 在线视频免费观看www动漫| 免费在线看污视频| 久久久久亚洲精品无码网址色欲 | 最近免费字幕中文大全| 亚洲精品国产国语| 亚洲不卡av不卡一区二区| 国产精品四虎在线观看免费| 51精品视频免费国产专区| 中文字幕免费在线看线人动作大片 | 亚洲一区二区三区在线视频| 噼里啪啦电影在线观看免费高清| 久久99久久成人免费播放| 黑人粗长大战亚洲女2021国产精品成人免费视频 | 久久免费观看国产99精品| 四虎永久在线精品免费一区二区 | 久久精品熟女亚洲av麻豆| 久久精品亚洲中文字幕无码麻豆| 亚洲美女在线国产| 色播在线永久免费视频| 国产精品色拉拉免费看| 国产精品免费高清在线观看| 国产精品高清免费网站| 高潮毛片无遮挡高清免费视频| 亚洲精品国产国语| 亚洲a视频在线观看|