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

  • SEARCH
  • Home
  • 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 7088247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:46:36+00:00 2026-05-28T07:46:36+00:00

After having some trouble with object deletion, I ran a simple test: Created a

  • 0

After having some trouble with object deletion, I ran a simple test:

  1. Created a simple class with a weak reference listener for Event.ENTER_FRAME.
  2. Added a trace("I Exist!") call to the listened function.
  3. Instantiated a single instance with one reference in the Document Class.

This worked as expected – the SWF file did nothing but print “I Exist!” every frame to the console. (In debug mode, of course.)

What I did next did not work as I expected:
I set the only reference of the object to be set to null on a mouse event, but the messages from the event listener of of said object still appeared in the console after the mouse event was fired and the reference set to null – meaning the object still existed!

Calling System.gc() in the document class IMMEDIATELY stopped the event listener from printing further messages and seemingly deleted the item.

From what I understand, calling System.gc() is discouraged, but as it seems from this simple test the garbage collector is a big FAIL.
Am I doing something wrong here in trying to dispose of the object, or should I simply call System.gc() every time I want to get rid of an object..?

Edit: Calling System.gc() with a non-weak listener also results in the object seemingly being removed from memory (?)

  • 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-28T07:46:36+00:00Added an answer on May 28, 2026 at 7:46 am

    Garbage collection is almost always deferred in modern VMs (Java, Flash Player, .NET, etc.). You can read http://www.adobe.com/devnet/flashplayer/articles/garbage_collection.html for more information.

    In particular:

    In Flash Player 9, the garbage collector’s operations are deferred. This is a very important thing to understand. Your objects will not be removed immediately when all active references are deleted. Rather, they will be removed at some indeterminate time in the future (from a developer standpoint). The garbage collector uses a set of heuristics that look at the RAM allocation and the size of the memory stack, among other things, to determine when to run. As a developer, you must accept the fact that you will have no way of knowing when, or even if, your inactive objects will get deallocated. You must also be aware that inactive objects will continue to execute indefinitely, until the garbage collector deallocates them, so your code will keep running (enterFrame events will continue), sounds will keep playing, loads will keep happening, other events will keep firing, and so on.

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

Sidebar

Related Questions

I'm having some trouble programmatically causing an HTML checkbox object to become highlighted after
I'm having some issues understanding how to reference new browser windows after opening them.
I'm having some trouble saving some data after using PHP's simplexml_load_file function. I want
Am having some trouble hooking up instance variables in the visual object editor using
I'm having some trouble with plain old JavaScript (no frameworks) in referencing my object
I'm creating an asteroids game and in my main class I'm having some trouble
Folks, I am having some trouble working with the After hook. I have organized
I'm trying to experiment with xampp. After having some space issues, I wanted to
I'm having the weird problem that after having javascript inject some dom-elements the css-rules
I am having some issues with logging. After reviewing JBoss Seam source code, 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.