# AddChild slow!

**URL:** <https://forum.kirupa.com/t/addchild-slow/283891>\
**Category:** flash\
**Created:** [March 12, 2009, 6:23am UTC](https://forum.kirupa.com/t/addchild-slow/283891 "2009-03-12T06:23:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BeerOclock](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@BeerOclock](https://forum.kirupa.com/u/BeerOclock)\
**Post date:** [March 12, 2009, 6:23am UTC](https://forum.kirupa.com/t/addchild-slow/283891/1 "2009-03-12T06:23:05Z")

</div>

Can anyone think of a reason why addChild would be very slow?

I have some code like this:

```auto

for (i=0; i<100; i++) {
 infoSprite = new CInfoSprite(this);			
 CProfiler.start("addChild");
 CCanvasManager.canvasSelections.addChild(infoSprite);			
 CProfiler.finish("addChild");
}

```

The output from the profiler looks like this:

profile ‘addChild’ took 14 millis  
profile ‘addChild’ took 15 millis  
profile ‘addChild’ took 17 millis  
profile ‘addChild’ took 18 millis  
profile ‘addChild’ took 19 millis  
profile ‘addChild’ took 19 millis  
profile ‘addChild’ took 18 millis  
profile ‘addChild’ took 18 millis  
profile ‘addChild’ took 20 millis  
profile ‘addChild’ took 20 millis  
profile ‘addChild’ took 21 millis  
profile ‘addChild’ took 20 millis  
profile ‘addChild’ took 21 millis  
profile ‘addChild’ took 21 millis  
profile ‘addChild’ took 22 millis  
profile ‘addChild’ took 22 millis  
profile ‘addChild’ took 25 millis  
profile ‘addChild’ took 25 millis  
profile ‘addChild’ took 28 millis  
profile ‘addChild’ took 26 millis  
profile ‘addChild’ took 29 millis  
profile ‘addChild’ took 29 millis  
profile ‘addChild’ took 30 millis  
profile ‘addChild’ took 30 millis  
profile ‘addChild’ took 32 millis  
profile ‘addChild’ took 34 millis  
profile ‘addChild’ took 34 millis  
profile ‘addChild’ took 34 millis  
profile ‘addChild’ took 36 millis  
profile ‘addChild’ took 35 millis  
profile ‘addChild’ took 36 millis  
profile ‘addChild’ took 38 millis  
profile ‘addChild’ took 38 millis  
profile ‘addChild’ took 39 millis  
profile ‘addChild’ took 38 millis  
profile ‘addChild’ took 40 millis  
profile ‘addChild’ took 41 millis  
profile ‘addChild’ took 42 millis  
profile ‘addChild’ took 43 millis  
profile ‘addChild’ took 42 millis  
profile ‘addChild’ took 43 millis  
profile ‘addChild’ took 46 millis  
profile ‘addChild’ took 45 millis  
profile ‘addChild’ took 46 millis  
profile ‘addChild’ took 46 millis  
profile ‘addChild’ took 48 millis  
profile ‘addChild’ took 48 millis  
profile ‘addChild’ took 48 millis  
profile ‘addChild’ took 48 millis  
profile ‘addChild’ took 48 millis  
profile ‘addChild’ took 50 millis  
profile ‘addChild’ took 50 millis  
profile ‘addChild’ took 51 millis  
profile ‘addChild’ took 51 millis  
profile ‘addChild’ took 51 millis  
profile ‘addChild’ took 52 millis  
profile ‘addChild’ took 55 millis  
profile ‘addChild’ took 53 millis  
profile ‘addChild’ took 59 millis  
profile ‘addChild’ took 66 millis  
profile ‘addChild’ took 55 millis  
profile ‘addChild’ took 55 millis  
profile ‘addChild’ took 56 millis  
profile ‘addChild’ took 57 millis  
profile ‘addChild’ took 58 millis  
profile ‘addChild’ took 57 millis  
profile ‘addChild’ took 57 millis  
profile ‘addChild’ took 59 millis  
profile ‘addChild’ took 61 millis  
profile ‘addChild’ took 61 millis  
profile ‘addChild’ took 60 millis  
profile ‘addChild’ took 59 millis  
profile ‘addChild’ took 60 millis  
profile ‘addChild’ took 60 millis  
profile ‘addChild’ took 62 millis  
profile ‘addChild’ took 62 millis  
profile ‘addChild’ took 62 millis  
profile ‘addChild’ took 63 millis  
profile ‘addChild’ took 63 millis  
profile ‘addChild’ took 64 millis  
profile ‘addChild’ took 63 millis  
profile ‘addChild’ took 65 millis  
profile ‘addChild’ took 65 millis  
profile ‘addChild’ took 67 millis  
profile ‘addChild’ took 66 millis  
profile ‘addChild’ took 66 millis  
profile ‘addChild’ took 66 millis  
profile ‘addChild’ took 67 millis  
profile ‘addChild’ took 69 millis  
profile ‘addChild’ took 70 millis  
profile ‘addChild’ took 70 millis  
profile ‘addChild’ took 71 millis  
profile ‘addChild’ took 70 millis  
profile ‘addChild’ took 71 millis  
profile ‘addChild’ took 72 millis  
profile ‘addChild’ took 71 millis  
profile ‘addChild’ took 71 millis  
profile ‘addChild’ took 72 millis  
profile ‘addChild’ took 72 millis  
profile ‘addChild’ took 73 millis

So not only is it very slow, it gets incrementally slower with each call. The whole thing takes over 6 seconds for these 100 objects being added. 100 sounds like a lot but Ive done other projects where Ive added 1000+ objects without any major slowdown like this.
