Memory Leak: How to destroy attachet MC

I’m developing flash control which plays images from WebCam as video. By each request FrameProcessor.aspx returns JPEG from my WebCam. It’s working fine. To avoid caching I’ve added random value to URL. My Flash control is working fine, but I have a problem with memory - each second Flash.exe grows up to 2-4 Mb. It takes about 1-2 minutes to fill all my memory :slight_smile:


var imageLoader:Loader;
 
function loadImage(url:String):void 
{
    // Set properties on my Loader object
    imageLoader = new Loader();
    imageLoader.load(new URLRequest(url));
    imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
loadImage("http://localhost/Racing/FrameProcessor.aspx");


function imageLoaded(e:Event):void 
{

    if (imageArea.child != null)
    {
        //I've tried to resolve issue with memory with these lines:
        imageArea.removeChild(imageLoader);
        imageLoader = null;
    }
    imageArea.addChild(imageLoader);
    // Load Image
    loadImage("http://localhost/Racing/FrameProcessor.aspx?rnd=" + Math.random());

}
 
function imageLoading(e:ProgressEvent):void 
{
    // Use it to get current download progress
    // Hint: You could tie the values to a preloader :)
}

Please note: imageArea is empty movieClip on the scene.
Could somebody help me to resolve memory leak? How should I destroy attached to imageArea movie clip to free memory?
Thank you!