Objects & Garbage Collector

HI,
When, exactly GC removes some object from memory? Does this code
Object obj = new Object();
obj = null;
System.gc;
guarantee that the obj is already removed from memory?
Thanks for some help
KM

Thanks for some helpIBM has an interesting series about garbage collection. This article for example,
http://www-128.ibm.com/developerworks/java/library/j-jtp01274.html

Similar Messages

  • I have a memory leak, objective-c 2.0, and garbage collector...

    the code i am using is a modification of the code/problem found in "Cocoa with Objective-C", chapter 3.
    i have tried to use the objective-c 2.0 garbage collector methodology, using @property, @synthesize, etc. when i run the code as listed below i get a leaking message.
    [Session started at 2008-02-01 23:33:37 -0500.]
    2008-02-01 23:33:38.070 SongsFoundationTool[28876:10b] * _NSAutoreleaseNoPool(): Object 0x2040 of class NSCFString autoreleased with no pool in place - just leaking
    Stack: (0x96b10178 0x96a3e0f8)
    2008-02-01 23:33:38.075 SongsFoundationTool[28876:10b] Song 1: We Have Exposive
    2008-02-01 23:33:38.076 SongsFoundationTool[28876:10b] * _NSAutoreleaseNoPool(): Object 0x2060 of class NSCFString autoreleased with no pool in place - just leaking
    Stack: (0x96b10178 0x96a3e0f8)
    2008-02-01 23:33:38.078 SongsFoundationTool[28876:10b] Song 2: Loops of Fury
    The Debugger has exited with status 0.
    when i include the commented out section, in the implementation file section, the description method, and use song1 and song2, in main, instead of song1.name and song2.name the program seems to run fine.
    The Debugger has exited with status 0.
    [Session started at 2008-02-01 23:38:24 -0500.]
    2008-02-01 23:38:24.375 SongsFoundationTool[28936:10b] Song 1: We Have Exposive
    2008-02-01 23:38:24.379 SongsFoundationTool[28936:10b] Song 2: Loops of Fury
    The Debugger has exited with status 0.
    please help me understand what's happening here.
    also, why was it necessary to use
    @property(copy, readwrite) NSString *name;
    @property(copy, readwrite) NSString *artist;
    instead of
    @property(readwrite) NSString *name;
    @property(readwrite) NSString *artist;
    thanks everyone, the code is below.
    // ....................... header file ...............
    #import <Cocoa/Cocoa.h>
    @interface Song : NSObject {
    NSString *name;
    NSString *artist;
    @property(copy, readwrite) NSString *name;
    @property(copy, readwrite) NSString *artist;
    @end
    //.................... the implementation file ..................
    #import "Song.h"
    @implementation Song
    @synthesize name;
    @synthesize artist;
    -(NSString *) description
    return [ self name ];
    @end
    //................................ main............................
    #import <Foundation/Foundation.h>
    #import "Song.h"
    int main (int argc, const char * argv[]) {
    Song *song1 = [ [ Song alloc ] init ];
    song1.name= @"We Have Exposive" ;
    [ song1 setArtist: @"The Future Sound Of Londown" ];
    Song *song2 = [ [ Song alloc ] init ];
    [ song2 setName: @"Loops of Fury" ];
    [ song2 setArtist: @"The Chemical Brothers" ];
    // Display Object
    NSLog( @"Song 1: %@", song1.name );
    NSLog( @"Song 2: %@", song2.name );
    // include statements below if -description method is uncommented
    // then comment out the two statements above. no memory leak if the code
    // is used from the statements below and - description is not commented out and
    // the two NSLog statements above are commented out.
    NSLog( @"Song 1: %@", song1 );
    NSLog( @"Song 2: %@", song2 );
    return 0;
    }

    Normally, your main only has a call to NSApplicationMain(). If you aren't doing a traditional MacOS X application, you will still want at least NSApplicationLoad() to get enough of the runtime to avoid those messages.
    I don't know for sure about the syntax of Objective-C 2.0. That stuff is all new. What error message are you getting that indicated that (copy, readwrite) is required? Could you provide a link to the actual example source? I did a quick check and assign and readwrite are the defaults. It is possible that readwrite by itself makes no sense. But I'm just guessing.

  • How does the Garbage Collector handle reference-free objects?

    Hi,
    I am interested to know how the GC handle's objects created
    without a reference.
    The reason this has become of interest to me is that I have
    created a "Title" class. The Title class animates each letter of
    Title.text to appear in a cloud of smoke.
    The smoke is a simple particle system class, when a particle
    dies it removes it's associated MovieClip so that eventually all
    MovieClip's have been destroyed.
    Now in the Title class for each letter I do the following
    (psuedo-code):
    for( Title.text.length) {
    CurrentLetter.twAlpha = new Tween( blah, blah, blah); //
    object created
    with a reference
    new Smoke( CurrentLetter.x, CurrentLetter.y); // object
    created
    without a reference
    Although this is technique is not one I would ever have
    thought of in a language that doesn't use a garbage collector it is
    mentioned in the Tween documentation and my class works as
    intended.
    The thing is although it works, it always bothers me when I
    don't know precisely
    why it works!
    If it's working due to the short life span of the class in
    question and thus simply missing the GC's window then this could be
    problematic. If at some point it is still alive when the GC is
    called then my class could be prematurely deleted.
    Maybe a class which has a reference to an "alive" MovieClip
    is immune from GC?
    I Hope someone can shed some light on this topic as the GC is
    something that is thinly documented to say the least!
    :theory
    p.s. first post!

    Hi,
    I would say it would be better use FREE itab at the end of the processing in your code. In the end-of-selection in your code, you can FREE all your itabs that were used in the program. This is one of the good approach of optimizing the memory.
    Regards
    Vimal

  • Incremental Garbage Collector is halting my server for MINUTES at a time.

    I have a Java server which services hundreds (currently 300-700 on average, target of 2000+) of simultaneous client connections, with a staggering number of long lived (but not permanent) objects.
    The docs for incremental garbage collection state: "The incremental garbage collector, which is off by default, will eliminate occasional garbage-collection pauses during program execution." This is NOT true in my case. During peak load, the Server halts occasionally (once an hour or more) and entire MINUTES tick by. Average wait time is 2.5 - 3.5 minutes, the highest I have seen is 4 minutes, 10 seconds. This is entirely unnacceptable.
    The server is on Red Hat Linux 6.2, kernel 2.2.14-5.0, with a gig of RAM. My current command line options are
    java -server -Xincgc -Xms256M -Xmx900M
    And I have just added -verbose:gc to help analyze the gc performance. I have read the gc tuning guide at http://java.sun.com/docs/hotspot/gc/index.html but still feel rather clueless about what is the optimum setup for my particular application.
    I will of course start experimenting, but I was hoping to find a "wise old elf" who might give some useful pointers to accelerate the process, seeing as how the Server is already running in a production capacity, time is critical.

    Are you using a Java application server like Tomcat, Dynamo, WebLogic etc. ?
    In that case consider running several server instances on the machine, with the applicationserver's software load balancer. Find the amount of RAM allocated to the heap per serverinstance where garbage collection runs takes a couple of seconds, and don't allocate more than this to each server. Start as many servers as you have available RAM for.
    This is the approach recommended by application server vendors such as BEA http://edocs.bea.com/wls/docs61/perform/JVMTuning.html and ATG.
    A side benefit of this approach is that in case you get more concurrent users than your computer can handle, you already have the setup for spreading the load over several computers.

  • CORBA and garbage collector

    Hi,
    I�m writing a server with a method create(), which returns a new object supplying a home banking service for the clients.
    My question is : when a given client has finished with the home banking object, do I need to call the gc, or is there an efficient one with CORBA (a kind of distributed garbage collector) ?
    Thank you in advance

    Maybe you heard about Distributed Garbage Collector (DGC)? Don't rely on this, since IIOP does not support this. Use PortableRemoteObject.unexportObject() to make remote objects that are no longer in use available for garbage collection.
    Bert

  • How intelligent is the garbage collector?

    Hi all,
    I've got a question about how garbage collection works in an ABAP objects context.
    If there are no more references an object is cleaned up and the memory released. Fine.
    What about an object O1, which in turn creates another object O2. O2 however also contains a refernce to O1.
    When the original process completes, this leaves two objects that reference each other, but with no other contact to the 'outside world'. Is the garbage collector intelligent enough to dump them?
    Any input appreciated,
    Cheers
    Mike

    Hi,
    Thanks for the feedback. I am still not sure - you say 'when the program ends it's part'. This is exactly the point - when the program ends, do the objects remain because they still contain references to each other?
    More detail:
    The references are public instance attributes of both objects (different classes). I would prefer to use functional methods, but am stuck with public attributes which I'm populating in the constructor.
    So a process P declares a local var LV_O1 and does a CREATE OBJECT LV_O1.
    In the constructor of O1, it does a
    CREATE OBJECT me->ATTR_O2 to populate it's attribute with a reference to an instance of O2.
    O2 doesn't need to do a CREATE OBJECT, but assigns a ref to O1 to it's attribute ATTR_O1.
    So now O1 and O2 refer to each other by public attributes:
    O1->ATTR_O2 and O2->ATTR_O1.
    The big question is what happens when process P ends and it's variable LV_O1 ceases to exist?
    In case anyone's wondering about the overall wisdom of the design, they have to be public attributes (used in Workflow) and they have to refer to each other as instantiation may also happen the other way around.
    Cheers
    Mike

  • How the protected finalize method is called by garbage collector

    Dear All,
    I have a double regarding the calling mechanism of finalize method. The access specifier of finalize method is protected, not only that if a class overrides this method then also the finalize method can be protected in the subclass of Object. But the concept of protected access specifier is, from outside of the package it can be accessed only from subclass.
    The program (may be part of Garbage collector), which calls this (finalize) method mast not be in the same package (that is java.jang) nor it is a subclass of the class (whose finalize method it calls).
    Then how the finalize method is getting called by the garbage collector when it is protected?
    Regards,
    Gourab

    Refer to following link for the details
    http://www.me.umn.edu/~shivane/blogs/cafefeed/2005/09/why-is-finalize-method-protected.html
    The link gives answer to how a protected/private members are accessible to JVM or GC and why finalize is declared protected.

  • Find out references to objects (garbage collection)

    Is there an easy way to find out, which references prevent the garbage collector from collecting my old objects, which I expect should be collected? Something like System.out.println(...)

    if you just want an object to be garbage collected, just
    make sure you de-reference is completely.CMueller obviously doesn't know which references prevent garbage collection so naturally he cannot set those references to null, now can he?
    o = null; // sets the value to null and drops all the referencesThat is simply not true. Removing a reference to an object doesn't affect any other references to that object.
      Object o1,o2;
      //create an object and make o1 reference it
      o1=new Object();
      //make o2 reference the same object as o1 references
      o2=o1;
      //now there are two references to the object
      //make o1 reference null
      o1=null;
      //at this point there is still one reference (o2) to
      //the object and therefore the object is NOT garbage
      //which means that it can NOT be collected by the GC- Marcus Sundman

  • Stateless ejb staying live after a garbage collector

    Hi,
    I use an aplication based in struts, in the actions i call session that call cmps, both ejb are stateless.
    Every thing works fine until i make some stress test, when i find that the server (Websphere) stay out of memory. After this i found that my sessions and cmps are staying live after the garbage collector run and i don't know why because the thread already finish and the ejb are stateless.
    Anyone already have this problem, how can i clear the memory of this objects?
    Thanks in advanced
    Ricardo

    Adjust the size of your EJB pool. Just because your application is no longer using the objects doesn't mean that the container won't hang on to them for re-use (object creation is an "expensive" operation).

  • Automatic Garbage collector after JVM almost hit max value on weblogic ?

    Hi All,
    I have application on weblogic 10MP2. I use 4G JVM. My application getting slow when the usage of JVM hit arround 70-80% of max heap size. Unfortunatelly, the garbage collector didn't run when it hit that high. So to keep my application in good state, I need to MANUALLY hit the Perform GC to keep the JVM below 70%.
    Is there any settings to tell the JVM to perform GC when the free space of the JVM hit 30%?
    What will the weblogic do if one of the server in warning state? There is a settings in the weblogic to specify when it hit some percentage of free space, it will bring the server to warning state. Will it do the Garbage Collector?
    Need your help on this. I am tired of hitting the Perform GC button.
    Really appeciate your help.
    Thanks,
    Eric

    I am replying to my own post because I found a tool that
    helped me solve in two hours what I had been stumped on
    for the past few days.
    The Heap Analysis Tool.
    I had a major memory leak problem. I couldn't locate
    the source until I downloaded and used this tool(for free).
    This tool keeps track of memory used by objects,
    each objects references, objects references by each
    object, and all objects instances. All of this information
    can be obtained in html format for efficient traversing
    of object chains. I would highly recommend looking
    this tool over if you intend on doing memory intensive
    programming.
    In case your curious where my error was I had two problems
    which are now fixed. One. I had a couple of BufferedImages
    that were leaking 30MB RAM. Two. I didn't know that using
    ObjectStream's to read/write objects stored references
    to the objects being written(preventing garbage collection).
    Deffinately worth running the Heap Analysis Tool before
    pointing a finger at System.gc().

  • Understanding garbage collector output

    Hi all.
    My application uses an increasing amount of memory, and in order to solve the problem I have turned on the -verbosegc option. The output is as follows:
    <GC: managing allocation failure: need 1040 bytes, type=1, action=1>
    <GC: 504 milliseconds since last GC>
    <GC: freed 6530 objects, 288432 bytes in 10 ms, 35% free (661616/1887424)>
      <GC: init&scan: 1 ms, scan handles: 7 ms, sweep: 2 ms, compact: 0 ms>
      <GC: 4 register-marked objects, 7 stack-marked objects>
      <GC: 8 register-marked handles, 136 stack-marked handles>
      <GC: refs: soft 0 (age >= 32), weak 0, final 1, phantom 0>
    <GC: managing allocation failure: need 1040 bytes, type=1, action=2>
    <GC: 10 milliseconds since last GC>
    <GC: expanded object space by 1048576 to 2936000 bytes, 58% free>
    <GC: need to expand mark bits to cover 2560 bytes>Is any one able to explain this output for me? My problem is that the object space is expanded regularly and eventually the garbage collector writes "totally out of heap space" and an OutOfMemoryError occurs.
    My -version is
    java version "1.3.0"
    Java(TM) 2 Runtime Environment, Standard Edition
    Classic VM (build 1.3.0-1, native threads, jit)running on UNIX, Digital Alpha.
    Regards,
    Torben Lange

    Just a follow up on my memory leak problem which I have solved now.
    I had created a class which handles database connections. The constructor looked something like this:
    Connection connection;
    public DBConnection() {
      DriverManager.registerdriver(new myDriver());
      connection = DriverManager.getConnection(...);
    }My application creates an object of this class, uses it and then closes the object. This goes on all the time. (Yes, it could be handled another way by pooling database access or simply keep the connection open without closing it - but it isn't.)
    It seems that the registration of the driver in the constructor eventually will fill the memory - apparently the same driver is registered several times.
    Problem was solved when changing the code into the following:Connection connection;
    static boolean isRegistered = false;
    public DBConnection() {
      if (! isRegistered) {
        DriverManager.registerdriver(new myDriver());
        isRegistered = true;
      connection = DriverManager.getConnection(...);
    }Hope this could help others in the same situation.
    Regards,
    Torben Poort Lange

  • Error "The current garbage collector has no nursery"

    Has anybody any information on the error message "The current garbage collector has no nursery"? We received the following error message after starting the WLS in production mode:
    <2006-jan-25 kl 17:57 CET> <Error> <Management> <BEA-140001> <An error occurred while getting attribute TotalNurserySize on MBean se-i-ld09:Location=se-i-ld09-c01-s01,Name=se-i-ld09-c01-s01,ServerRuntime=se-i-ld09-c01-s01,Type=JRockitRuntime. Method: public long weblogic.t3.srvr.JRockitRuntime.getTotalNurserySize(). Exception: com.bea.jvm.NotAvailableException: The current garbage collector has no nursery..
    com.bea.jvm.NotAvailableException: The current garbage collector has no nursery.
         at jrockit.management.jvm.GarbageCollectorImpl.getNurserySize()J(Unknown Source)
         at weblogic.t3.srvr.JRockitRuntime.getTotalNurserySize()J(JRockitRuntime.java:112)
         at jrockit.reflect.NativeMethodInvoker.invoke0(Ljava.lang.Object;ILjava.lang.Object;[Ljava.lang.Object&amp)Ljava.lang.Object;(Unknown Source)
         at jrockit.reflect.NativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object&amp)Ljava.lang.Object;(Optimized Method)
         at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object&amp)Ljava.lang.Object;(Optimized Method)
         at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Optimized Method)
         at weblogic.management.internal.DynamicMBeanImpl.getAttribute(Ljava.lang.String&amp)Ljava.lang.Object;(DynamicMBeanImpl.java:574)
         at com.sun.management.jmx.MBeanServerImpl.getAttribute(Ljava.lang.Object;Ljava.lang.String&amp)Ljava.lang.Object;(MBeanServerImpl.java:1183)
         at com.sun.management.jmx.MBeanServerImpl.getAttribute(Ljavax.management.ObjectName;Ljava.lang.String&amp)Ljava.lang.Object;(MBeanServerImpl.java:1153)
         at weblogic.management.internal.RemoteMBeanServerImpl.getAttribute(Ljavax.management.ObjectName;Ljava.lang.String&amp)Ljava.lang.Object;(RemoteMBeanServerImpl.java:287)
         at weblogic.management.internal.RemoteMBeanServerImpl_WLSkel.invoke(ILweblogic.rmi.spi.InboundRequest;Lweblogic.rmi.spi.OutboundResponse;Ljava.lang.Object&amp)Lweblogic.rmi.spi.OutboundResponse;(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(Lweblogic.rmi.extensions.server.RuntimeMethodDescriptor;Lweblogic.rmi.spi.InboundRequest;Lweblogic.rmi.spi.OutboundResponse&amp)V(BasicServerRef.java:477)
         at weblogic.rmi.internal.BasicServerRef$1.run()Ljava.lang.Object;(BasicServerRef.java:420)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic.security.subject.AbstractSubject;Ljava.security.PrivilegedExceptionAction&amp)Ljava.lang.Object;(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(Lweblogic.security.acl.internal.AuthenticatedSubject;Lweblogic.security.acl.internal.AuthenticatedSubject;Ljava.security.PrivilegedExceptionAction&amp)Ljava.lang.Object;(SecurityManager.java:144)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(Lweblogic.rmi.spi.InboundRequest&amp)V(BasicServerRef.java:415)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(Lweblogic.kernel.ExecuteThread&amp)V(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(Lweblogic.kernel.ExecuteRequest&amp)V(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:178)
         at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread&amp)V(Unknown Source)>
    Thanks in advance for your help - it is much appreciated!
        Cheers, Jonas                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    This exception is thrown by the JRockit Management API when querying the nursery size of a GC that has no nursery (single-generational GC). The logical place to catch the error would be in the weblogic.t3.srvr.JRockitRuntime.getTotalNurserySize() method, which implies that it is a WLS issue.
    Maybe it has been fixed in a later WLS 8.1 service pack?
    If you run with a generational GC, i.e. "-Xgc:gencon" the error will go away, but that has larger implications on the behavior of your app so it should not be used as a workaround.

  • Problem with garbage collector -

    I'm experiencing a problem with the Java Garbage Collector.
    It simply doesn't work when I try to free the memory that is used
    by an object in my program...
    I explicitly declared this object as null, and called System.gc, but it seems it isn't working.
    What might be the reason?
    This object uses a lot of memory. Therefore, I MUST destroy it after it's no longer
    needed.

    Ok. I'll try to be more specific...
    My "situation" seems something like that
    class Program {
    Xclass class1;
    void method1() {
    class1 = new Xclass();
    } (End of class Program)
    class Xclass {
    Yclass class2;
    Public Xclass( ) {
    class2 = new Yclass();
    add(class2);
    } (end of class Xclass)
    class Yclass {
    Public Yclass(Container parent) {
    (no explicit reference to Xclass or Program classes or any variable or instantiations of said classes);
    } (end of class Yclass)
    Well, I know that the gc is not being done because the first time I call method1 everything goes fine. But When I try it again an OutOfMemoryError happens...
    I tried to do the following (I know, it's not elegant, but I just wanted to get some results):
    void method1() {
    class1 = null;
    System.gc();
    class1 = new Xclass();
    Again it worked in the first time. But later...

  • Garbage collector question

    I have a question about the garbage collection. You cant activate the garbage collector when you want but in JProbe tool you can request it pushing a button. Can i do this in my application?. I tried using System.gc() and Runtime.getRuntime.gc() but i cant get the same result. Any ideas?
    Thanks in advance and excuse me, my english is not so good.

    In Jprobe if you request a garbage collection you get
    a deep garbage collection that release much of the
    used heap size. But if i put in my code System.gc()
    only a little of space is released.The amount of released memory depends of course on the number of "unused" objects. If you allocate an array of bytes that's allmost the maximum size of the heap the JVM can use and you make it available for garbage collection by releasing the refernce the effect running the garbage collector is much bigger than if you only allocate an array of, let's say 32 bytes, and do the same. A complex GUI application allocates and releases lots of objects so it's possible to release a huge amount of heap space whereas a not so compex application uses fewer objects and there are less object to release by the garbage collector.

  • Garbage Collector Questions

    Howdy all,
    I've got a few questions about flash's garbage collector.  I'm building a  game and have all elements in a container sprite called _gameContainer.
    _gameConatiners contains other sprites such as _hudContainer which  contains more containers such as _gameoverContainer, _menuContainer,  etc.  So there's a whole hierarchy of containers that are all contained  in _gameContainer which is added directly to the document class (not the  stage btw).
    So the whole thing should basically be Stage -> Document Class -> _gameContainer -> etc.
    When the player loses or wants to restart the game, I'm removing all  event listeners (which are defined as weak, but still rather make sure  there's no loose ends), stopping all music/sounds, removing  _gameContainer from the stage, and then setting _gameContainer to null.   From there I am re-calling my init function which creates everything  (_gameContainer, and everything inside of it, as well as creating all the  standard eventlisteners).
    Am I doing everything upside down?  Is this *a* proper way of restarting  a game?  Mind you I dont say "the" proper way since I'm sure there's a  hundred different ways to do this.
    Also, on a separate note... If I have something such as an enemy, I keep all  enemy logic contained in the class linked to the movieclip on the  stage.  Who should be calling add/removechild?  Should I be using a  factory method that takes care of all this, or should I have the engine  create the enemy, and then have the enemy remove itself from stage?   Currently I'm using a mix of both, but generally I'll have a function in  the engine/caller add it to stage, then have the class have an  ADDED_TO_STAGE event listener.  When it comes time to remove the class, I  have it call it's own removeself function such as: (_container is a  reference to it's container as mentioned above such as _hudContainer)
    protected function removeSelf():void
        if(_container.contains(this)) {
            _container.removeChild(this);
        _container.parent.parent.dispatchEvent(new Event(Engine.START_GAME));
    Thanks!

    Wonderful question Travisism.
    The garbage collection is strange.  First I'm curious why you lump displayObjects into _gameConatiners.  Does _gameConatiners get added to the stage at any point?  Why not just add the proper hud at the point its required?
    Anyhow.  By removing listeners ,removeChild(_gameConatiners), and setting _gameConatiners=null does not mean these classes are killed.  null only marks the memory locations as having no more references to them.  When this occurs these objects may be removed from memory.  Why do I say may, that is because it takes a specific amount of memory utilized to trigger the garbage collection.
    Now just merely setting _gameConatiners=null may not ever kill your objects off.  You would be required to profile this and make sure they are dieing properly.  From the sounds of it you have a lot of inner children.
    There is reason to believe that in some cases, when an object is removed from the main stacks that its children will be removed as well.  Though, if the inner workings are so large, often the objects within referencing each other effects the way the garbace collection is stating they are still in use.  Thus keeping these objects alive.
    Its always best to kill off every reference being used.  You can do this by ensuring each object in your movieClip class declared a kill method, and continue trickeling down each object.  This ensures each object will be properly marked.
    As far as your movieClips a factory method is only for the creation of objects, never for the removal.
    You're best bet is to have an object that holds all objects on the stage in a collection.  When you destroy the game. Itterate through this collection and remove them from the stage there.
    This would fit into your engine concept.  There is no reason to use a displayObject for that since its just an object.  Better Yet use a Vector.<DisplayObject> to optimize this.
    Back to your question is this *a* proper way to reset.
    Yeah and No.  The asnwer is based on the memory usage your application eats, and the amount of time to rebuild all objects.  Ideally you should Pool any resources that can be reused versus having to rebuild.
    For example.  If you have a screen that says Game Over.  why would you have to rebuild it on a reset?  There is no information that was changed.   Each clip instantiation takes memory allocated and time.
    Unfortunately without seeing what you have its difficult to say.  But init methods are good and it can be wise to rebuild objects to being again, but as i said it depends.
    Lastly, your line:
    _container.parent.parent.dispatchEvent(new Event(Engine.START_GAME));
    Should not have parent.parent references within.  If you are creating a new Event, at least fall back on eventBubbling to allow the event to travel to the parent.parent.
    You should never target parents like that in a class.  Best practices is to pass in parent.parent as a reference to the class.
    What if you were to add one more layer of parents to the _container.  Then you would have to continue modifying parent.parent.parent.  At least if you bubble the event you dont have to be concerend at all about who listens to it.

Maybe you are looking for

  • Transaction variant not working

    Hey, I am facing with this peculiar problem of transaction variant. I created a transaction variant as desired by my client for VA01 and activated the same. I checked the status in the transaction VA01 and there it showed that the transaction variant

  • How to translate the text dynamically in the program?

    Hi All, I have a requirement where I need to translate the text dynamically in the program based on the Language Key retrieved. Let's say that the Login language is 'EN' and in the logic has retrieved the language 'IT'(based on some conditions). I ha

  • Categeriastion schema and Service Ticket

    Hi i have to add fileds in categorization schema .this can be done by using EEWB,but how can i see this transaction in UI     i have to add two new buttons in the sales ticket view ..already one button ist here in that view but i am unable to get the

  • Profile Manager - webauthd LDAP authentication

    I'm trying to make Lion Server talk to an simple OpenDS directory server. After jumping through a series of hoops to get everything (iChat, Directory Utility) working, I now had to look into Profile Manager. Now, Apple has put up a support article at

  • Bounding box tracelines in pdf

    Hello assorted gurus and geniuses. Apologies if this query isn't in the most appropriate forum, or if it has been answered a hundred times before. I have looked and failed to find, honest! I produce a regular magazine (on InDesign CS4) with a full pa