title: Flash Builder 4 Profiler: how to spot what objects are causing a known memory increase?
body: <p>I know profiler questions can be quite general, but here I have a very specific question and example.</p>
  
  <p>I know that in the following code (taken from <a href="https://stackoverflow.com/questions/4928457/why-wont-this-move-effect-work-on-my-sprites-when-the-fade-effect-does/">Joshua's question</a>), that an infinite number of <em>circle</em> object instances are being added to the <em>hostComponent</em>. This obviously causes gradual slowing down of the app. </p>
  
  <p>My question is, when I run the Flash Builder Profiler, where exactly do I see where the problem lies? </p>
  
  <p><a href="http://bbishop.org/flex/03_MovingCircles/MovingCircles.html" rel="nofollow noreferrer">Running example of the app</a> </p>
  
  <p>To try it out, create a new Flex 4 project, and paste in this code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                 xmlns:s="library://ns.adobe.com/flex/spark" 
                 xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
                 initialize="onInit()" viewSourceURL="srcview/index.html"&gt;
      &lt;fx:Script&gt;
          &lt;![CDATA[
              import mx.core.UIComponent;
              import mx.effects.Fade;         
              import spark.effects.Move;
  
              private var hostComponent:UIComponent;
  
              private function onInit():void{
  
                  hostComponent = new UIComponent();
                  hostComponent.id = "circleHostComponent";
              }
  
              /* Add circle UIComponent objects to the hostComponent.
                  Move and Fade the circle objects */
              private function onTimerEvent(event:TimerEvent):void{  
  
                  var yPos:Number = Math.ceil(Math.random()*100);
                  var radius:Number = Math.ceil(Math.random()*5); //1-12
                  var effectAlpha:Number = Math.random()*0.5 + 0.2 // 0-1
                  var effectDuration:Number = Math.ceil(Math.random()*3000) + 1000;
  
                  var circle:UIComponent = new UIComponent();
                  circle.graphics.beginFill(0x1C75BC, effectAlpha);
                  circle.graphics.drawCircle(90, yPos, radius);
                  circle.graphics.endFill();
  
                  hostComponent.addChild(circle);
  
                  var moveEffect:Move= new Move(circle);
                  moveEffect.xBy = 300;
                  moveEffect.duration = effectDuration;
  
                  moveEffect.play(); 
  
                  var fadeEffect:Fade = new Fade(circle);
                  fadeEffect.alphaFrom = 1;
                  fadeEffect.alphaTo = 0;
                  fadeEffect.duration = effectDuration;
  
                  fadeEffect.play();
  
                  this.addElement(hostComponent);
  
              }
  
              private function onClick():void{
                  startButton.enabled = false;
                  var t:Timer = new Timer(100, 0);
                  t.start();
                  t.addEventListener(TimerEvent.TIMER, onTimerEvent);
  
              }       
  
          ]]&gt;
      &lt;/fx:Script&gt;
  
      &lt;fx:Declarations&gt;
          &lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;
      &lt;/fx:Declarations&gt;
  
      &lt;s:Button id="startButton" label="Click to Start" click="onClick()" /&gt;
  &lt;/s:Application&gt;
  </code></pre>