A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Remove from Vector... will it be gc'd?

  1. #1
    Señor Member Mavrisa's Avatar
    Join Date
    Oct 2005
    Location
    Canada
    Posts
    506

    Remove from Vector... will it be gc'd?

    Hi, I'm creating a simulation in which a large number of objects are added to vectors and then taken away in random order (as more are being added).

    To remove the objects, I splice the object from the vector it's in, and notify all the other objects that an object ahead of them was removed so they can change their indices accordingly.

    As far as I know, the objects have no other references (I think), and within the object, I set everything to null. I read somewhere that you can't put "delete this" in the class, so I didn't bother with that.

    Will this be sufficient to get the object garbage collected, or should I do something else? What are the best ways to get something like this garbage collected?

    Thanks,
    Mavrisa
    Haikus are easy
    But sometimes they don't make sense
    Refrigerator

  2. #2
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    As long as they aren't display objects on the chain and there aren't any other ref's, collection should kick in almost immediately when they're spliced from the vector. If there's any question, refer to this thread:

    http://board.flashkit.com/board/show...t=active+graph

    I posted the code for a good class called ActiveGraph there (not written by me) that's useful for testing whether you're getting collection. Read the thread for details about how to use it...

  3. #3
    Señor Member Mavrisa's Avatar
    Join Date
    Oct 2005
    Location
    Canada
    Posts
    506
    Awesome! thanks
    Haikus are easy
    But sometimes they don't make sense
    Refrigerator

Tags for this Thread

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