# Loader won't clear from memory

**URL:** <https://forum.kirupa.com/t/loader-wont-clear-from-memory/331675>\
**Category:** flash\
**Created:** [September 24, 2013, 1:38pm UTC](https://forum.kirupa.com/t/loader-wont-clear-from-memory/331675 "2013-09-24T13:38:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![straris](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@straris](https://forum.kirupa.com/u/straris)\
**Post date:** [September 24, 2013, 1:38pm UTC](https://forum.kirupa.com/t/loader-wont-clear-from-memory/331675/1 "2013-09-24T13:38:50Z")

</div>

[SIZE=4][COLOR=#000000][FONT=Arial]I have been struggling on this for some time. I have a loader that loads an external image every ten seconds. My problem is that although i have tried all kind of things to clear it after i am done with it, it keeps consuming more memory every time it loads the image.[/FONT][/COLOR]  
[COLOR=#000000][FONT=Arial]As you can see, in the end of the code i am trying everything that i could find without any results. The memory usage keeps getting bigger every time the **myLoader.load(fileRequest)** occurs.[/FONT][/COLOR]  
[COLOR=#000000][FONT=Arial]Any thoughts?[/FONT][/COLOR]  
[COLOR=#000000][FONT=Arial]:-([/FONT][/COLOR][/SIZE]

```auto
[COLOR=#00008B]var[/COLOR] tenSec:[COLOR=#2B91AF]Timer[/COLOR] = [COLOR=#00008B]new[/COLOR] [COLOR=#2B91AF]Timer[/COLOR]([COLOR=#800000]1000[/COLOR],[COLOR=#800000]10[/COLOR]);
[COLOR=#00008B]var[/COLOR] image:[COLOR=#2B91AF]DisplayObject[/COLOR];
[COLOR=#00008B]var[/COLOR] myLoader:[COLOR=#2B91AF]Loader[/COLOR];

tenSec.removeEventListener([COLOR=#2B91AF]TimerEvent[/COLOR].TIMER_COMPLETE, onTimerComplete);
tenSec.addEventListener([COLOR=#2B91AF]TimerEvent[/COLOR].TIMER_COMPLETE, onTimerComplete);
tenSec.start();

[COLOR=#00008B]function[/COLOR] onTimerComplete([COLOR=#00008B]event[/COLOR]:[COLOR=#2B91AF]TimerEvent[/COLOR]):[COLOR=#00008B]void[/COLOR]
{
  myLoader= [COLOR=#00008B]new[/COLOR] [COLOR=#2B91AF]Loader[/COLOR]();
  myLoader.contentLoaderInfo.removeEventListener([COLOR=#2B91AF]Event[/COLOR].COMPLETE, onLoaderReady);
  myLoader.contentLoaderInfo.addEventListener([COLOR=#2B91AF]Event[/COLOR].COMPLETE, onLoaderReady, [COLOR=#00008B]false[/COLOR], [COLOR=#800000]0[/COLOR], [COLOR=#00008B]true[/COLOR] );

  [COLOR=#00008B]var[/COLOR] fileRequest:[COLOR=#2B91AF]URLRequest[/COLOR] = [COLOR=#00008B]new[/COLOR] [COLOR=#2B91AF]URLRequest[/COLOR]([COLOR=#800000]"http://"[/COLOR]+ip+[COLOR=#800000]"/radiosite/image.jpg?nocache="[/COLOR] + [COLOR=#00008B]new[/COLOR] [COLOR=#2B91AF]Date[/COLOR]().getTime());
  myLoader.load(fileRequest);
  [COLOR=#00008B]function[/COLOR] onLoaderReady(e:[COLOR=#2B91AF]Event[/COLOR])
  {
     image = myLoader.content;
     addChild(image);
     image = [COLOR=#00008B]null[/COLOR];
     myLoader.unload();
     myLoader = [COLOR=#00008B]null[/COLOR];
     [COLOR=#2B91AF]System[/COLOR].gc();
     fileRequest = [COLOR=#00008B]null[/COLOR];
  }
  tenSec.reset();
  tenSec.start();

}

```
