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

Similar Messages

  • In the Suite, how does the email portion handle spam?

    In the Suite, how does the email portion handle spam?

    Every email message you mark as spam (and also mark the ones that aren't spam that went in to your junk folder) helps it learn over time.
    If you want more (extremely) technical information about it: http://en.wikipedia.org/wiki/Bayesian_spam_filtering

  • How does the iPhone 3G handle this???

    If I save photos from my email, and there are multiple photos with the same name, how does the iPhone 3g behave? Since I can't see the filenames of the photos, I am unable to determine if any two images have the same filename.
    Does the phone rename one? Overwrite one? What occurs??

    That is exactly what I was talking about. I expected as much however I noticed the following occur. I save a photo from one source, and saved the exact same photo from another source (both have the same filename) I then deleted the first one that I saved, and both photos were deleted.
    Is that the proper behavoire?

  • How does the (ABAP) AS handle unused internal tables? (garbage collection?)

    Hi,
    Let's suppose i have a class, which contains a simple method like follow:
    method do_this.
      data lt_table type something_tab.
      "do some manipulation on the lt_table.
    endmethod.
    So during runtime, at the moment when we leave the method "do_this", will the lt_table memory space be freed? Or is it still allocated? Do we need to use an explicit "free lt_table" statement?
    I want to optimise memory usage in my code, and was wondering if such explicit calls to "free" is necessary.
    Thank you,
    Edited by: Huynh Van Du Tran on Mar 16, 2009 6:38 PM

    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

  • How does the Edge E540 handle audio? (e.g. DPC Latency)

    Hi, I know that some other Lenovo models have problems with very high DPC latency, causing drop outs and crackles while using CPU-heavy audio programs (music productiong, DJing etc), but I couldn't find any info specific to the Edge E540. So do any of you have experiences (good/bad) with the Edge E540 and audio?

    Hallo T1MUR,
    vielen Dank für den Hinweis. Hat's gebracht!
    Thanks a lot for that hint, I followed your suggestions and it worked just fine. The scripts you provided in my case all appear to just switch off KbdMgr.exe without leaving me with a lot of choices. I still have to figure out whether this behaviour can be improved by editing your batch files. For the time being it probably would suffice to kill the process in the windows task manager and to switch it on again if needed by double clicking it in the c:\programs\boot camp directory. One then has to reenable the function keys manually, whereas all other tunings affected by boot camp are kept. This is slightly inconvenient, but it's ok. The differences may be due to the fact that I am dealing with a MacBook Air, not a MacBook Pro.
    Thanks again for your help, I really appreciated this.
    Siggi Engelbrecht

  • How to get the garbage collector to work?

    Hi,
    i have i program where i load an image scale it down and save the scaled version in an array. I do this for a whole directory of images.
    After every image i set the temporary variable for the loaded image = null and call the function System.gc().
    My problem is, that the garbage collector does�nt give the memory of the loaded image free and the used memory of my program grows with every loaded image.
    /* Reads all images from a folder an stores them in an Array of images */
         public static BufferedImage[] readScaledImagesFromFolder(String folder,
                   int maxSize) {
              File dir = new File(folder);     /* Open the Folder */
              String[] children = dir.list();          /* Get the children of the folder */
              if (children == null) {
                 // Either dir does not exist or is not a directory
                  System.out.println("No images in the folder!");
                  return null;
             } else {
                  /* Init array for images */
                  BufferedImage[] images = new BufferedImage[children.length];     
                  int i = 0;
                  int index = 0;
                  BufferedImage temp;
                  String filename, fileending;
                 for (i=0; i<children.length; i++) {
                      // Get filename of file or directory
                     filename = children;
         /* Get the fileending of the file */
         fileending = filename.toLowerCase().substring(filename.length()-4);
         if(fileending.equals(".jpg") || fileending.equals(".bmp")
                   || fileending.equals(".png") || fileending.equals(".gif"))
              /* Read the image */
              temp = util.ImageUtils.loadBufferedImage(folder+"/"+filename);
              /* Scale the image down and save it in an array */
              images[index] = Util.getScaledImage(temp,maxSize);
              index++;          
         temp = null;
         System.gc();
         Mosaic.sourceImageNum = index;
         System.out.println((index+1)+" resized pictures loaded from folder: "+folder);
         return images;     
    How can i get the gargabe collector to work after every iteration?
    I tried to let the Thread.sleep(10) after System.gc() but it does�nt help.
    Thank you every much
    JackNeil

    Hm yes.. i now that System.gc() is only a
    suggestion.
    But i know what my program is doing and that it
    does�nt need the temporary image anymore after i have
    a scaled down version. And the temporay image will become unreachable as soon as reading the next one overwrites your temp variable. Setting the variable to null doesn't have much effect.
    It would be smarter to load the new image over the
    old temporary image and not to expand the heapsize to
    maximum.Then look at the possibitly of loading the next image into the same bufferedimage.

  • 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 does the iMac handle HD video editing?

    Tired of Window PCs, looking to buy an Apple System. I would like to do some video editing but want to make sure I get a powerful enough system from the start. How does the iMac handle HD video editing or should I look a better, faster computer?

    I have a mid 2011 iMac, 21 inch 4 GB RAM (the next to bottom iMac), Lion. I run Final Cut Express 4 with no difficulty (at least so far). It is certainly fast enough. My old G5, 7 years old, was also, and the iMac is faster.
    As I remember, I heard from someone on the Final Cut Express Discussions that some people might be having difficulty with FCE 4 on Lion, but I am a bit hazy. Its bigger brother, Final Cut Pro, is also available. I suggest that you post on the Final Cut Express or Final Cut Pro Discussion sites. They have many reliable users.

  • How does the SDK and Reader handle printing with orientation?

    I have a document that I want to print, and it contains a portrait page on Page 1, and a landscape page on Page 2.  Acrobat Reader correctly prints these pages (with a single print job), and I'm assuming it's because of the auto-rotate option on the print dialog.  Is this a feature of Reader, the API, or how the printer handles the request.  I've tried printing this PDF just using the JAva API, but the orientation remain portrait for all pages.  How does the Adobe Acrobat API deal with mixed orientation pages?  Ignore the fact that I did my test printing with Java, because my question is whether or not the auto orientation is a feature of the UI, the SDK, or the printer (or a combination).

    Same as the current Ipod Video or "Classic" there is an option under settings to toggle between original aspect ratio or Full Screen.
    Kenal0

  • How does the email program in the suite compare with Google GMail especially in handling spam or are both about the same?

    How does the email program in the suite compare with Google GMail especially in handling spam or are both about the same?

    Firefox doesn't include an email client. Are you asking about the Seamonkey suite? The Seamonkey support options are over here: http://www.seamonkey-project.org/community

  • Swing components and the garbage collector

    How much care does one need to take with swing components, with reference to running out of stack space? I ask because I'm writing a system for an automotive parts company, and the company tends to not reboot the machines very often...
    Anyway... if a JFrame is closed, is it and all its components marked for GCing? Do I need to call the dispose method, or is this part of the default close behaviour? Or is there something else entirely?
    Cheers

    In class that calls for .setVisible(false) of one JFrame u MUST call
    for dispose() method.
    so
    myFrame.setVisible(false)
    myFrame.dispose()
    myFrame = null // to help the garbage collector
    If u have classes that becames from JFrame (or JDialog) u can
    invoke in its constructors:
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
    This makes uncecessary to call for dispose() method explicetly.
    If u do not have this kind of classes u can invoke this method
    after u have create your JFrame
    JFrame myFrame = new JFrame();
    myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
    The most important thing is REMOVE ALL LISETNERS that u have added, so, if u have classes that becames from JFrame u can ovverride
    the dispose method to do that
    eg
    public void dispose()
    super.dispose()
    removeActionListener(.....)
    and so on
    If u do not have this kind of classes u must remove all listeners u have
    added before u invoke the setVisible(false) method.
    Regards

  • How does the remote object connect to the correct host

    i have had a small doubt on how the remote reference manages to find the correct host to call the subsequent methods after a sucessful lookup.
    given a rebind or bind to the registry, the registry only stores the alias and the remote reference, now imagine a client calling a lookup on the registry would only get the remote reference, and not in which machine the remote object is found.
    what i wanted to know is how does the client or atleast the remote reference returned by the registry correctly connects to the machine where the remote object is located. i dont think its stored in the stub bcos the stub is a complie time stuff.
    i would be pleased to have a comprehensive answer for this.

    The membership in the group communication framework is always accurate and upto date.Up to date to the moment when you check. Not up to date to the moment when you make the RMI call.
    i could basically chk if this ip is available in the membership list.Complete waste of time. It doesn't matter what you check ahead of time, you are still trying to predict the future.
    And you still have to deal with ConnectException etc from the actual remote method call. And the way you will deal with that in your situation is exactly the same as what you were going to do if your ahead-of-time check failed.
    So just catch the exception(s) and deal with the problem there.

  • How does the URL of DataSocket constitute?And how to use it in LabWindows/CVI ?

    Hi !
    There's a problem puzzled me some days.How does the URL of DataSocket constitute ? And how to use it in LabWindow/CVI ?
    For example.I have downloaded a code in http://zone.ni.com/devzone/cda/epd/p/id/3787.I want to make it work properly.So I configure my DataSocket Server Manger according to the URL of this statement.
    DS_Open ("dstp://weather.natinst.com/weather/current",
    DSConst_ReadAutoUpdate, DSCurrentCallback, NULL,
    &dsCurrentHandle);
     My DateSockket Server Manger is configured as:
    However,it could not work properly when I debug it.
    There's a introduction at the top of the code."You may need to replace the references to weather.natinst.com to 130.164.140.10 if the DNS isn't working properly."So,I modified the statement into
    DS_Open ("dstp://130.164.140.10/weather/current",
    DSConst_ReadAutoUpdate, DSCurrentCallback, NULL,
    &dsCurrentHandle);
    but,it did work properly.
    We want to communicate with other computers via the URL of  DataSocket in LabWindows/CVI.Whereas,how could we make it ia the URL ?
    If anyone could help me solve this problem,I would appreciate it very much !
    Best regards.
                     xiepei
    I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.

    Hi !
    Thank you very much for your reply! I will accept your advice.
    Besides,I have another question.If I want to visit other computers or other websites,how does the URL of DataSocket  I constitute ? Does the URL has any relation with the DataSocket Server Manger ?If does,how to configure the DataSocket Server Manager to let them connected.If they have no relation,how to use the DataSocket Server Manger ?
    After all,I want to know how to use it in LabWinows/CVI ?
    Thank you very much !
    Best regards!
    I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.

  • How does the Touch screen look in direct / indirect sunlight?

    Was sitting on the LIRR heading home when I had this thought... after watching some guy playing with his PSP, as the sun was falling on his screen.... hhmmmm, I wondered how my Touch, which is now enroute from Anchorage, is going to handle the sunlight hitting it? Will I be able to watch my movies/tv shows without problem? How does the Touches screen look when sunlight hits it. I realize that sunlight hitting the screen is not an optimal viewing situation, but couldn't help but think how it would look. Those that are lucky to have one.... how does it handle sunlight?

    readable, but not great. I had it out in bright Ozzie sunshine and I could use it, but I wouldn't watch a movie on it.

  • How does the original iPad mini perform on iOS 8?

    I have been thinking about getting a new iPad from the iPad 2. I know the original iPad mini and the iPad 2 have similar specs, but the real upgrade I get from it is the wireless technology and the ability to use Handoff. Overall, how does the original iPad mini handle iOS 8? Should I go with that iPad or get the iPad mini 2? I wouldn't get the iPad mini 3 because I don't think Touch ID is necessary for what I want to do on an iPad.
    Overall, I am wondering how iOS 8 performs on the original iPad mini so it can help me choose between the original or the iPad mini 2. Thanks in advance for your input!

    Get the mini 2 when the prices come down. The mini 2 is baically a smaller iPad Air. The improvements over the mini are well worth the money.
    http://www.apple.com/ipad/compare/#comparison-chart

Maybe you are looking for