A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: garbage collection questions

  1. #1
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588

    garbage collection questions

    If i create a contianer that holds several sprites like so.
    PHP Code:
    var sprCon = new Sprite();
    addChild(sprCon);
    var 
    spr0:Sprite = new Sprite();
    var 
    spr1:Sprite = new Sprite();
     var 
    spr2:Sprite = new Sprite();

    sprCon.addChild(spr0);
    sprCon.addChild(spr1);
    sprCon.addChild(spr2); 
    then if I remove sprCon all the children go with it but does that mark them for garbage collection or do I need to remove all refrences to those sprites inside the container also?
    ~calmchess~

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    You would need to remove the references to the children. Because for example, you remove sprCon. You could then turn around and do: myOtherSprite.addChild(spr0) without any problem.

  3. #3
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    ok i have another question about refrences to children that i remove ....if it is a textField and i have textField.style set do i have to unset that or set it null in order to get rid of a refrence ? exactly what is considered a refrence?
    ~calmchess~

  4. #4
    Senior Member
    Join Date
    Nov 2005
    Posts
    192
    Quote Originally Posted by calmchess View Post
    ok i have another question about refrences to children that i remove ....if it is a textField and i have textField.style set do i have to unset that or set it null in order to get rid of a refrence ? exactly what is considered a refrence?
    I am pretty sure you only have to make sure that nothing references textField.style like

    b=textField.style;
    b is a reference btw.

    So if you did something like that do
    b=null;

  5. #5
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    I need more help i have refrences such as tField.type = null ......and tField.x = null. but these refrences don't accept null as a value what do I do for those?
    ~calmchess~

  6. #6
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Try undefined or void - although I don't think you need to clear all the properties out for an object to get cleared. I believe the GC will mark and sweep entire groups of objects that are interconnected but otherwise unused by your code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center