String memory leak?
I've been programming for some time in AS3 and found a really weird problem with strings that for no apparent reason are hanging on the memory, the program below just changes the label.text property with a random string, it works fine but when i looked at the Flex profiler i noticed that the number of Strings is increasing steadly, i tried executing the garbage collector but didnt helped me.
Is this a memory leak? how can i solve it?
As I know this strings should be collected by the garbage collector because there are no objects referencing them, yet this is not happening for all the strings.
Heres the code and a screenshot of the Flex profiler showing the number of String instances.
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="windowedapplication1_creationCompleteHandler(event)">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected var t:Timer=new Timer(10);
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
t.addEventListener(TimerEvent.TIMER,listener,false,0,true);
t.start();
}
protected function listener(e:Event):void
{
var s:String=Math.random()+"-->";
this.fx(s);
s=null;
}
protected function fx(s:String):void
{
this.label.text=s;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Label id="label" y="39" left="10" right="10" text="Label"/>
</s:WindowedApplication>

