0 Replies Latest reply on Dec 12, 2008 12:56 PM by Someonewhere

    Loader leaking

      Couple issues. If you do this:

      oLoader = new Loader();

      oLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, OnDownloadError, true);
      oLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, OnSecurityError, true);
      oLoader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, OnHttpStatus);
      oLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, OnDownloadComplete);
      oLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, OnProgress);
      oLoader.contentLoaderInfo.addEventListener(Event.OPEN, OnOpen);

      oLoader.load(new URLRequest(_strURL));

      Here's my "Destroy" function which does get called:

      oLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, OnDownloadError, true);
      oLoader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, OnSecurityError, true);
      oLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, OnDownloadComplete, true);
      oLoader.contentLoaderInfo.removeEventListener(HTTPStatusEvent.HTTP_STATUS, OnHttpStatus);
      oLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, OnProgress);
      oLoader.contentLoaderInfo.removeEventListener(Event.OPEN, OnOpen);

      And then do it over and over again downloading the same file, destroying it with the above call, your memory keeps growing and growing. Never stops, never gets released.

      Also, if you try to download a file that doesn't exist on the server and then handle the HTTP_STATUS 404 error by calling that destroy function, you get an exception upon leaving the function. This happens for Loader and the URLLoader classes.

      URLLoader error: "Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: <snip>..."
      Loader error: "Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed."

      So how do I unregister my event listeners on an error? If the file is downloaded properly, calling my destroy function causes no issues.

      Anyway, this is unrelated to the Loader leak. Does the Loader class require a DisplayObjectContainer to operate properly?

      Happy coding.