3 Replies Latest reply on Apr 8, 2007 5:25 PM by GMina

    Flex Component Memory Leak

      In my application, I need to have many instances of RichTextEditor, but it seems, that they are not properly garbage collected, after I remove them. So the application slows down over time.
      Here is a little script, that shows the problem:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      import mx.events.FlexEvent;
      import mx.controls.RichTextEditor;

      protected function btnClick() : void
      for (var i : int = 0; i < 10; i++)
      var obj : DisplayObject = new RichTextEditor();

      obj.addEventListener(FlexEvent.CREATION_COMPLETE, function(event : Event) : void

      label1.text = String(System.totalMemory / 1024 / 1024);
      <mx:Button x="36" y="21" label="Button" click="btnClick()"/>
      <mx:Label x="36" y="83" text="Label" id="label1"/>

      My memory usage raises to 20MB after I click the button 4 times.
      This doesn't happen with simpler components.
      Any suggestions?

        • 1. Re: Flex Component Memory Leak
          usually, the origine of this problem comes from the delay between 2 instances of the garbage collector (~1mn). if the processes are too fast, it will be harder to clear correctly.

          At least, that was the origine of my problem
          • 2. Re: Flex Component Memory Leak
            hupfnudel Level 1
            But this is a strange thing to happen.
            I mean, there must be some reference to the instances. But where are they, when I remove the components? Some events that are not removed maybe? Or is it really a problem of the garbage collector?
            • 3. Re: Flex Component Memory Leak
              It appears that Flex is riddled with memory leaks... has anyone actually had a positive experience with the GC? I just started working with Flex, and everwhere I turn the most simple things turn into a memory leak. Is there some hidden function @ mx.core.Application.application.dontLeakMemory(true) ?