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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:52:32+00:00 2026-05-25T17:52:32+00:00

Initially I had ten arraycollections declared in a flex module, which I thought, were

  • 0

Initially I had ten arraycollections declared in a flex module, which I thought, were causing a memory leak. So I separated them in a single class, which I would clean using the “destroy” method I created inside it. Would this work?

I hate the question title excuse me. But I wouldn’t write it like “Seducing the garbage collector”

        [Bindable]
        public class Cfd
        {
            private static var instance:Cfd = new Cfd();
            private var _cfds:ArrayCollection = new ArrayCollection();

            // Constructor
            public function Cfd(){
                if (instance) { throw new Error('Cannot create a new instance.  Must use Cfd.getInstance().') }
            }

            public static function getInstance():Cfd{
                return instance;
            }

            public function get cfds():ArrayCollection{
                return _cfds;
            }
            public function set cfds(value:ArrayCollection):void{
                _cfds = value;
            }

            public function destroy():void{
                if(_cfds != null){
                    _cfds.removeAll();
                }
                }
}
  • 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-25T17:52:32+00:00Added an answer on May 25, 2026 at 5:52 pm

    Whenever you use Singletons like this, you pretty much guarantee a memory leak, because you’re probably listening to the ArrayCollection (and maybe items within it) from all over the place. When you explicitly provide a reference to an object through a getter/setter pair, you can add the listener in the setter and removie it when the value is reset.

    Check out http://www.developria.com/2010/08/rethinking-addeventlistener-an.html for more on what’s happening.

    For more on why you should avoid Singletons http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars

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

Sidebar

Related Questions

Ok, so I have an application that reads another processes memory. I initially had
In my iphone app, I had initially divided the app into modules. Each module
I have multiple apps running which access a sql server database. I had initially
I recently wrote a program that used a simple producer/consumer pattern. It initially had
Initially I had a method in our DL that would take in the object
For this assignment I had to create my own string class. I initially wrote
Initially I thought this was going to work, but now I understand it won't
Initially I had the issue reported in this question . Now, what I noticed
I have created a list in SharePoint 2010, initially had the columns Title, Mobile
Initially I had the following: [Flags] public enum QueryFlag { None = 0x00, CustomerID

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.