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 7855619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:26:28+00:00 2026-06-02T20:26:28+00:00

I know that event listeners and references to an object will prevent the garbage

  • 0

I know that event listeners and references to an object will prevent the garbage collector from dealing with objects. My question is, will an event listener placed on an object, listening to the same object, prevent that object from being garbage collected?

I ask because it seems like this is happening to me. I am breaking all my references to an object but I am still seeing traces when its timer goes off. At the same time, it seems like this should not prevent the collection because it would create allocated but unreferenceable 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-06-02T20:26:29+00:00Added an answer on June 2, 2026 at 8:26 pm

    No, but.

    The AVM2 garbage collector is supposed to find unreachable objects. But because garbage collection is non-deterministic, it’s very hard to rely on or even test this behaviour — it could be that the garbage collector is working perfectly, but not bothering to run the mark-and-sweep since you have enough RAM free.

    It’s a good idea to remove event listeners when you’re done with the object, even if they’re from the object itself (i.e. circular references). Why is this a good idea? Because you never know when the garbage collector is going to run. If you want deterministic behaviour, always remove listeners in a deterministic fashion, especially for time-sensitive events like TIMER and ENTER_FRAME, otherwise you’re creating a race condition between your listeners running and the garbage collector running. The garbage collector only runs periodically.

    In general, if you want to attach event listeners without creating an additional reference to the object, pass true to the useWeakReference parameter of addEventListener(). If you want to stop receiving the events right away, though, you’ll still need to manually detach your event listeners as soon as you’re done with the object.

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

Sidebar

Related Questions

I know that the GC collects objects that have no references pointing to the
I want to know if it is possible to make an event listener that
I know that the live() event handles event bubbling different than all other jQuery
I know that we can use onPause() event to stop the MediaPlayer using reset()
I want to know that can mouse click event detects colors or even strings.
I have some code that creates a new event source: EventLog.CreateEventSource(Source, LogName); I know
I'm looking for an updated answer to this question . It seems that Event.observers
I know both languages are from the same ECMA-262 standard. It seems that the
I'm trying to migrate from using inline event triggers to using event listeners using
I wanted to know that which events are triggered when there is a page

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.