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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:17:27+00:00 2026-05-11T11:17:27+00:00

I want to delete/force garbage collection on a class instance from inside itself .

  • 0

I want to delete/force garbage collection on a class instance from inside itself. Obviously, this = null and delete this don’t work. Is it any way I can do that, or am I barking up the wrong tree? I’m basically looking for a destructor of some sort..

I have a class instance that attempts to load an XML file, and if the file is not found, I want to destroy the instance, preferably from inside itself. The point is then to do some things in the parent class depending on whether the child instance is null or not.

I’ve thought of throwing an event to the parent and delete the child from there, but I’d prefer to do that only if there’s no other way.

  • 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. 2026-05-11T11:17:28+00:00Added an answer on May 11, 2026 at 11:17 am

    You shouldn’t attempt to remove object from itself – it is a bad practice, and in AS3 you can’t do it for sure.

    Object may be deleted (i.e. garbage collected) only if there are no references left to that object. Since references always get passed by value and object is generally not aware of which references to it exist, you can’t delete object from itself. The only useful thing you can do is to create a method which will clean up all resources used by an instance. Such method will serve as a destructor, but you’ll have to call it manually. Don’t forget that event listeners will also prevent garbage collection unless you remove them.

    There is also a difference between delete‘ing a property and setting it to null. Effectively delete will remove a property from an instance of dynamic class. Whereas setting property value to null will not remove the property, but erase any reference that was stored there. Therefore both actions will destroy the reference that was stored in some property. Note, that you can’t delete an object, only a property.

    There are certain hacks that can be used to initiate garbage collection in flash players 9 and older ones. However recently System.gc() call got available, which does the same thing. Note, that you can’t really rely on the fact that GC will actually be called. This is up to the flash player.

    Returning to your question: throwing event and notifying parent that something went wrong is actually a good idea. You should stick to it. Moreover, it is better if parent will know of such event that way, and not when it will discover that some properties got magically nulled.

    P.S.: Reading Grant Skinner articles on memory in flash player is actually a good idea.

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

Sidebar

Ask A Question

Stats

  • Questions 179k
  • Answers 179k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer JavaScript can always be tampered with. By hashing the password… May 12, 2026 at 3:55 pm
  • Editorial Team
    Editorial Team added an answer I'm currently using xsd2code.net, find it here: http://xsd2code.codeplex.com/. Lots of… May 12, 2026 at 3:55 pm
  • Editorial Team
    Editorial Team added an answer It's probably best to run a small actual calculation (with… May 12, 2026 at 3:55 pm

Related Questions

When I try to commit SVN reports about 10 old directories as missing. I've
I've got a weird thing going here in Powershell 1.0 and I don't understand
I have a query that, basically, says this: SELECT DISTINCT [DB_ID] FROM [TableX] WHERE
You'd think that it would be simple, isn't there something simple to do this?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.