Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7191153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:40:06+00:00 2026-05-28T19:40:06+00:00

I noticed something dangerous while working with AS3 – some objects (namely DisplayObjects /

  • 0

I noticed something dangerous while working with AS3 – some objects (namely DisplayObjects / MovieClips) tend to remain in the memory and even perform actions after all references to them have been removed.

I work with Flash CS 5.5 and Flash Builder 4.6.

After getting rid of all references (including removeChild(…) from the Document Class) some objects just seem to stay alive.

This question might come off as a bit broad – but what I am trying to understand is what can I do to MAKE SURE that an object is picked up by the Garbage Collector?
More so, how can I get some sort of feedback from the GC that signifies that a certain object has been destroyed? (For example, a console message)

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:40:07+00:00Added an answer on May 28, 2026 at 7:40 pm

    Removing the object from the stage, removing event listeners and setting all references to null should be enough – GC will pick it up when it is next executed.

    It is tedious to keep track of all references, however (and remember this includes event listeners, unless you’ve set useWeakReference to true), if you don’t have a standard way of doing it… It is advisable to have a “destructor” function in every class, which takes care of cleaning up all variables and event listeners when an object is no longer needed.

    You can combine these with events, too – I’ve come to think that it is good practice to execute your init() function on Event.ADDED_TO_STAGE and the destroy() function on Event.REMOVED_FROM_STAGE. That way you have a clearly defined life cycle for stage objects, and if you make sure your destroy() method stops all animations and sounds, removes all children and event listeners and sets all member variable fields to null, you can be quite sure there’s no longer any activity going on that could produce unwanted side effects.

    By the way – if you actually notice any activity by an object you have removed, some references must certainly still be intact – how else would you be able to tell?

    Still, there’s no way to know when exactly GC will pick up a discarded object – this is managed by the VM, and you’re not going to get a message when it is done. And it shouldn’t be your responsibility to think about when to free memory – after all, that’s exactly what garbage collectors were invented for!

    If you make it a habit to clean up after yourself, your programs will unavoidably become more stable, consume less memory and ultimately perform better. That’s all that should matter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just noticed something that I'd never noticed before, while working on a (regular,
I noticed something while uploading some unicode data to the database. When the content
For a long time now I have noticed something annoying when working on Web
Programming for my Arduino (in some kind of mix of C/C++), I noticed something
i have just noticed something strange in some asp.net markup. I have a standard
I was looking through some legacy code we have and I noticed something that
I noticed something strange while executing a select from 2 tables: SELECT * FROM
I was creating a http module and while debugging I noticed something which at
If you've been programming for a while then you probably noticed something completely impossible
I am working on a WCF SOAP service, and I noticed something weird. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.