How to Perm Gen space garbage collected?

Hi,
Im using a small utility to start & stop Embedded Tomcat [both utility & Tomcat are in a single JVM]. The effect of start & stop is that, the classes are not getting unloaded on stopping the Tomcat container & classes are getting reloaded on each & every start,there where no traces of unloading of classes.
So results in Out of Memory Exception : Perm Gen Space.
Trials i had are
1. Called destroy of the Tomcat class loader
2. Used GC option CMSPermGenSweepingEnabled
but no results.
Please let me provide solution.
Thanks in advance,
Edited by: user7362843 on Oct 7, 2010 9:36 PM

What VM are you using?
Classes are unloaded, at least in normal desktop VMs, when the class loader that loaded them is unloaded.
Since you are stating that more than one class of the same type is being loaded that by definition means that you are using class loaders. So allowing those to be collected would allow the old classes to be collected.

Similar Messages

  • Perm gen space error on redeploy.

    After about 5 to 6 times of redeploying or stopping and starting of our application, the perm gen space eventualy runs out of memory and the container freezes.
    I've noticed (with jprofiler) that all the static classes especially singletons are kept in memory after an undeploy and no memory are released in the perm gen space even on a forced garbage collection.
    We do not want to restart the container every time because another applications will then also be affected.
    We are using Oracle 10.1.3 and JDK 1.5 update 11.
    Any help to remove the singletons from memory would be appreciated.
    Thanks.

    There are various explanations for this issue. One is that usage of XML is the issue, the other one is class loading (from a comment in the JDK). You should check your application for both. It might help for future use.
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Regarding Perm  Gen Space

    Hello,
    when i am working with myeclipse i got one error message, that is about Perm Gen Space...... i found some infomation about that, it is regarding non-heap memory and we mention this in ecllipse.ini file......
    wright now i just want to know what is this perm gen space ... and what is the role that played in this.... is this regarding VM

    The permanent generation is for objects that the vm wants the garbage collector to manage that are not actually allocated by the java application. I.e. interned Strings etc.

  • How to specify when Full Garbage Collections occur in the Old Generation

    Hi. We seem to be having a problem with a number of JVMs (1.5.0_17-b04) that run a component of a Document Management application. This component stores a large amount of information in caches which reside in the Old Generation. Although these cache sizes can be somewhat controlled by the application, they are currently taking about 85% of the Old Generation space. Fortunately, very few objects get tenured into the Old Generation - they all are cleaned up in the New Generation space.
    The problem we are seeing is that with the Old Generation at 85% full, there are constant full GC's occurring. Since the caches cannot be removed, the system frantically tries to remove objects that can't be removed.
    We have three solutions in mind. The first is to increase the memory allocation to the Old Generation so that the caches take a smaller percentage of the available memory allocation. The second would be to decrease the size of the caches; but this is set more by the number of documents in the application and cannot be made much smaller.
    The third solution is to configure the JVM so that Garbage Collections in the Old Generation do not occur until the memory is more than a specific percentage of memory in the Old Generation. We would then set this percentage to be higher than the amount of memory being used by the caches.
    So, is it possible to tell the JVM to only run a Full GC when the memory in the Old Generation is greater than a specific value (say 85% full)?
    Thanks for your help.
    Andre Fischer.

    afischer wrote:
    The third solution is to configure the JVM so that Garbage Collections in the Old Generation do not occur until the memory is more than a specific percentage of memory in the Old Generation. We would then set this percentage to be higher than the amount of memory being used by the caches.
    So, is it possible to tell the JVM to only run a Full GC when the memory in the Old Generation is greater than a specific value (say 85% full)?Switch to the CMS collector.
    -XX:+UseConcMarkSweepGC
    -XX:CMSInitiatingOccupancyFraction=86

  • How to encourage jvm to garbage collect?

    Hello,
    I am working with an application that would benefit from more frequent garbage collection. It is running on a hefty machine, with multiple processors and more than 4 gigs of memory available for the JVM. Right now, we are setting the max heap size to 3 gigs.
    The problem is that objects are accumulating, but are not being collected. During a particular operation that I am profiling, over 1 gig of objects are created, but are never collected. If I do a manual garbage collect (using jprofiler), they are all collected. There is no good way to load these objects in another way, or to create fewer objects.
    I have spent a few days playing with -XX:MaxNewSize, -XX:NewSize, -XX:MaxHeapFreeRatio, -XX:TargetSurvivorRatio, and even -XX:+UseParNewGC. Unfortunately, I am unable to encourage the JVM to collect these objects automatically.
    Are there any tricks that I am missing? Does anyone know any good way to encourage the JVM to collect garbage after a certain threshhold in the new generation?
    Thanks,
    --Jeff                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You can try this!
    How do I set the JVM's heap size?
    On machines with limited memory (less than 384MB), it is recommended that you set the initial heap size lower than the default. Open the configuration file etc/netbeans.confin a text editor and modify the options in netbeans_default_optionssetting. Decrease the option -J-Xmx128mto -J-Xmx96m and the option -J-XX:MaxPermSize=96mto -J-XX:MaxPermSize=64m. Save the file and restart the IDE.
    Bear in mind that UI responsiveness may be affected when the heap utilization gets close to its limit. Should you encounter an OutOfMemoryError, you need to increase Xmx or XX:MaxPermSize back to the default, or even higher.
    Similarly when running on a machine with more memory it might be useful to increase the maximum size of the heap, especially when working with larger projects. Use the page linked below to get more details on this topic.
    Applies to: NetBeans 4.x, 5.0
    Platforms: All

  • How to make external SWFs garbage collected in Air for iOS?

    My app uses lots of external SWFs( well they are actually included in the app with a folder but they aren't embeded ) and they do not contain any bitmapdata, only vector graphics. The problem I'm having is that they seem to be never garbage collected and System.privateMemory keeps increasing as the app loads more SWFs.
    Since those SWFs only contain vector graphics, I simply nullify all the variables that are holding reference to SWF file and call System.gc().. But it doesn't seem to be working. What would I need to do for the garbage collector to clean the SWFs?
    I'm using Air for iOS 3.5.0.1060 and ActionScript3.0.

    Yes I'm calling System.gc() twice. I tried using loader.unloadAndStop(true) and it seems SWFs are being garbage collected but another problem has surfaced. When repeatedly loading and unloading SWF in a short period, the air garbage collector sometimes fails to work.
    I've tested loading and unloading same SWF 50k times and checked trace.  Occasionally, garbage collector misses to collect garbage like below( swf #45119 is not being garbage collected).
    [UnloadSWF] main.swf/[[DYNAMIC]]/45115
    [UnloadSWF] main.swf/[[DYNAMIC]]/45116
    [UnloadSWF] main.swf/[[DYNAMIC]]/45117
    [UnloadSWF] main.swf/[[DYNAMIC]]/45118
    [UnloadSWF] main.swf/[[DYNAMIC]]/45120
    [UnloadSWF] main.swf/[[DYNAMIC]]/45121

  • How can I prevent class garbage collection????

    Hi,
    Is there a way to prevent a class from being garbage collected without using the -noclassgc option? Is there some code I can include in a class that tells the JVM not to garbage collect that particular class?
    Thanks in advance,
    Jacob.

    The code shown below (slightly modified from yours) should work correctly on any 1.0.x throught 1.4 JVM.
    Look at this article for further info: http://www.javaworld.com/javaworld/javatips/jw-javatip52.html
    public class SQLManager extends PoolManager {
        private static SQLManager myself;
        //code.........................
        public static SQLManager getInstance() {
            // This version of a getInstance method suffers from the use of the
            // broken (unreliable) double checked locking idiom.  It should never
            // be used on a system with more than one processor and is ill-advised
            // any other time.  It can  lead to accesses to uninitialized objects.
            // See http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html
            // or http://c2.com/cgi/wiki?DoubleCheckedLockingIsBroken
            // So despite its common appearance in books and pattern repositories,
            // it should not be used.
            if (myself == null) {
                synchronized(SQLManager.class) {
                    if (myself == null)
                        myself = new SQLManager();
            return myself;
        private SQLManager() {
            livethread();
            //code.........................
        void livethread()
            System.out.println("##############################################################");
            System.out.println("###################Live Thread called#########################");
            System.out.println("##############################################################");
            Thread thread = new Thread()
                public void run()
                    // added this code to ensure that run() actually is getting
                    // called
                    System.out.println("##############################################################");
                    System.out.println("#################### Thread Started ##########################");
                    System.out.println("##############################################################");
                    Class myClass = SQLManager.class;
                    while (true)
                        try
                            synchronized (myClass)
                                myClass.wait();
                        catch (InterruptedException ex)
                            System.out.println("##############################################################");
                            System.out.println("###################Thread interrupted#########################");
                            System.out.println("##############################################################");
                        finally
                            System.out.println("##############################################################");
                            System.out.println("################### Something Happened #########################");
                            System.out.println("##############################################################");
                    System.out.println("##############################################################");
                    System.out.println("#################### Thread Dead?? ##########################");
                    System.out.println("##############################################################");
            thread.setDaemon(true);
            System.out.println("##############################################################");
            System.out.println("#################### Starting Thread #########################");
            System.out.println("##############################################################");
            thread.start();
        //code.........................
    }

  • Tomcat perm gen space

    When I reload my war file in tomcat about seven times it throws a PermGen space issue and is out of memory. What is the best way to diagnosis this problem to fix it? Thanks!

    There are various explanations for this issue. One is that usage of XML is the issue, the other one is class loading (from a comment in the JDK). You should check your application for both. It might help for future use.
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to avoid pauses in Garbage Collection

    While doing performance test on a full load we found pauses. We captured GC and here are few instances of Full GC. We are running JVM 1.5, JBoss 4.2.x on RedHat Linux. Could some one guide me in avoiding those 17 secs and 10 sec pauses. Thanks
    3643.602: [Full GC   [PSYoungGen: 23948K->0K(155328K)] [PSOldGen: 1819363K->728226K(1864192K)] 1843311K->728226K(2019520K) [PSPermGen: 58042K->58042K(60928K)] 17.8018000 secs]
    51867.636: [Full GC   [PSYoungGen: 1176K->0K(165824K)] [PSOldGen: 230161K->227209K(1864192K)] 231337K->227209K(2030016K) [PSPermGen: 58577K->58091K(58496K)] 4.1231000 secs]
    5862.403: [Full GC   [PSYoungGen: 41791K->0K(126400K)] [PSOldGen: 1843013K->421307K(1864192K)] 1884805K->421307K(1990592K) [PSPermGen: 58161K->58161K(58624K)] 10.8445660 secs]
    62677.562: [Full GC   [PSYoungGen: 1192K->0K(166528K)] [PSOldGen: 229211K->230214K(1864192K)] 230403K->230214K(2030720K) [PSPermGen: 58466K->58466K(58752K)] 2.8801950 secs]

    In general you need to use double buffering if you want to avoid flickering. That means that instead of painting directly to the window you paint to a bitmap and then paint that bitmap to the window.
    There are probably plenty of articles on the internet about the subject, here's one I found on a quick search:
    http://www.codeproject.com/Articles/33/Flicker-Free-Drawing-In-MFC
    One thing that may be worth noting is that in some cases most of the flicker comes from the default painting of the window background. In some cases simply avoiding that (see the OnEraseBkgnd change in that articles) removes most of the flicker.

  • Garbage collection

    String string1 = "Test"; 
    String string2 = "Today"; 
    string1 = null; 
    string1 = string2; i want know how many objects have been garbage collected by the JVM in this code .
    is there any function of JVM which can tell me how many have been garbage collected for this code.
    here its a small code. the reason i am asking , for large code it would difficult to track manually for garbages. . so is there any way out ?

    for large code it would difficult to track manually
    for garbages. . so is there any way out ?There is an easy way out: stop worrying about it.
    You don't need to "track" garbage. That's the beauty of garbage collection. It's mostly automatic (as long as you don't do anything silly in your code, such as build a huge data structure, and keep it stored in a global variable forever even though the program will never use the data again.)
    Are you a C++ programmer by any chance? I find that sometimes C++ programmers who run into a garbage collecting system tend to obsess about it needlessly, because so much time and attention has to be spent twiddling with memory allocation in C++.
    How many objects does System.gc() collect? Maybe none. Maybe one. Maybe more. System.gc() might not collect anything at all; it might schedule garbage collection to happen at a later time. There are asynchronous garbage collectors that run in their own threads, collecting whenever the cpu has a few spare cycles. Asking "how many objects are collected at point X in the code" makes no sense on those systems.

  • Applescript: force garbage collection?

    Hello
    I am trying to call applescript functions (from my cocoa application - using NSAppleScript's -executeAndReturnError), to automate some operations in Microsoft Word.
    The problem is that after every Applescript call, the Word operates slower and slower (and i guess finally it won't respond at all). I am calling operations, like "set myvar to all words of current document whose [some conditional]" or "set myvar to all fields of current document whose [some conditional]" (which are memory consuming - on each call Word enumerates all the words of a long document, searches there some matches, etc), and i think that after each call of NSAppleScript's -executeAndReturnError, Word doesn't clean its previous "results", which slows it down with every next call. I wanted to try to do an explicit call of Applescript's garbage collector after each -executeAndReturnError from my Cocoa app, maybe that could eliminate the problem i have.
    But i didn't find any info on how to do that. Java, ActionScript - both have System.gc() functions (that launch Garbage collection if it's needed right here and right now). If theres no way to force garbage collecting in AppleScript, maybe someone knows "implicit ways", when AppleScript engine calls it? Like the next iteration of a loop, or some other conditions? Or some timespan, after passing which the GC is called?
    What could cause that slowness of Mac:Word? Is it a mistake of Microsoft, or am i forgetting to do something? If someone could advice readings about how applications usually implement Applescript interface "from the inside" (and who is responsible for cleaning the results of each call), i'd be very thankful.
    Thanks for any advice!
    George

    If you really want to see the results you should also run the finalizer
    thread on the newly garbage collected objects. It might take up to 2 GC
    cycles for the memory to be actually free for new allocation at least on
    the Sun JVMs. Maybe the new types of garbage collectors do it better or
    more optimized but anyway, the GC would first mark the objects and only
    then the finalizer will run to call the finalize method. Then next GC
    will free the memory of the finalized objects.
    HTH,
    Dejan
    Dinesh wrote:
    Hi Slava Imeshev,
    Thanks for immediate response. I agree JVM will do GC at specific interval. But,
    I have found that , there is some difference in both of them. If you invoke "Force
    Garbage Collection" explicitly, the graph will show the heap memory usage to baseline.
    Where in, if you perform System.gc(). It won't make much difference.
    Thus why, I want to know what is the code behind the "Force Garbage Collection"
    button.
    Thanks,
    -Dinesh.
    "Slava Imeshev" <[email protected]> wrote:
    "Dinesh" <[email protected]> wrote in message news:406a8df4$[email protected]..
    How can i schedule "Force Garbage Collection" to be done at every
    week or daily?.
    Can i automate this process instead of manually invoking the button?
    GC is already done by JVM automatically.
    Why would you want to "schedule" it?
    Regards,
    Slava Imeshev

  • Tracing Garbage Collection

    I need to implement a program illustrating the performance loss to java through the automated garbage collection Vs controlling the garbage collection manually using java real time programming.
    How can I determine when garbage collection is performed by the virtual machine? For instance could I launch a thread to monitor the garbage collection and return feedback when collection is in progress?
    Thanks

    I have been using this method on my object to write to a file.
    protected void finalize() throws RemoteException {
    try{
    Date now = new Date();
    String s = "Garbage Collection was here\n Date: "+now + " Object: " + this.getName()+"\n";
    byte abyte0[] = s.getBytes();
    FileOutputStream fileoutputstream = new FileOutputStream("garbageplanner.txt", true);
    fileoutputstream.write(abyte0);
    fileoutputstream.close();
    }catch (Exception e){}
    }

  • How strong ,soft ,weak ,phantom references are used in garbage collection

    Hi
    to all here.I have doubt that how garbage collection is deciding to cleaning up heap , and what are the roles of strong , soft , weak and phantom reference in garbage collection, i went throgh sun's java docs but i couldn't get any clear idea about those , please can anyone explain me with nice examples for which i will be really thankful.

    See:
    http://java.sun.com/developer/technicalArticles/ALT/RefObj/

  • How to Change the Garbage Collection Algorithm in WLS 9..2

    Hi All
    I am trying to find out the way to configure the GC algorithm in weblogic 9.2 to type bea.Jmapi.GarbageCollector@.
    By default it is showing ‘Nursery, parallel mark, parallel sweep’ . We were trying to change it to generational (two-spaced) with a parallel mark algorithm and a concurrent sweep algorithm or bea.Jmapi.GarbageCollector .
    To change the same I modified the memory argument in commenv.cmd to set MEM_ARGS=-Xms128m -Xmx256m -XXsetGC:genparcon
    Still Garbage Collection Statistics section in web logic console shows the same default value.
    Could anyone tell me if I am missing something?
    thanks in advance

    There is nothing is WebLogic that will define the JVM GC algorithm, that is up to the JVM settings that are normally configured using params in the start scripts.
    If you are using JRockit, you can ask in the forums but the JVM documentation should really be sufficient.
    JRockit
    Same thing for the Sun JVM, there is lots of information out there on how to change the GC algorithm.
    The thing that is nice about JRockit is that you can use the Mission Control tooling to take recordings, look at the GC's and make adjustments easily. Sun has some tooling as well with jvmstat (and visualgc), but I'm not as familiar with it.
    http://java.sun.com/performance/jvmstat/
    Both of those tools would be much preferred to printing the GC info to a file and trying to parse it in my opinion.

  • How garbage collection works in spring framework?

    Hi,
    Whether we are using or not, all objects are created and stored in beanfactory in spring frramework.
    So how garbage collection will work here?
    Thanks in advance

    It depends on the scope, by default beans are singletons and will not be garbage collected.
    http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#beans-factory-scopes

Maybe you are looking for

  • Acrobat 10 Pro vs Acrobat 9 Pro Extended

    Fellow Forum Members, Has Adobe dropped the Typewriter tool that Acrobat 9 had?  Also Acrobat 9 Pro Extended had an app called Presenter. Has this also been dropped?  Can anyone out there post a list of what features have been dropped from Acrobat 10

  • Indesign cs4 keeps crashing on startup

    My Indesign cs4 crashes when it shows the recent documents dialog box, it never fully loads, just shows the white box then hangs for a while until it crashes finally. Im running Mac OS X 10.5.8. Crash report included, it's pretty long... Thanks in ad

  • IPS Tech Tip - Evasions - TCP/IP examples and handling - Sig team presentation

    Hi Customers, Its summer time and nothing evokes cool quite like a discussion into the TCP / IP stack and how creative attacker types try to hide attacks behind it. This presentation will feature a security researcher from our signature team and wil

  • Find/Change resources

    Where are the files stored which you saved in the Find/Change window. I can't find them in the Preset folder.

  • Problems with Multi-Polygon and creating index on it

    I have a multipolygon that was created from a SDO_AGGR_UNION and I'm trying to create an index on the geometry. It is failing with... ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine ORA-13249: internal error in Spatial index: [m