1 Reply Latest reply on Sep 4, 2008 10:41 PM by anirudhs

    JPEGAsyncEncoder memory problems

    seme1
      When running the following code on several images,, there appears to be a memory leak (memory keeps increasing and never freed after each run)
      ========================================
      var bd =new air.BitmapData(500,400);
      bd.draw(tmploader ); //tmploader is a new air.loader
      var encoder = new window.runtime.com.pfp.utils.JPEGAsyncEncoder();
      encoder.PixelsPerIteration = 128;

      encoder.addEventListener(
      window.runtime.com.pfp.events.JPEGAsyncCompleteEvent.JPEGASYNC_COMPLETE, function(e){
      encodeDone(e, lastid, propid);
      encoder.removeEventListener(window.runtime.com.pfp.events.JPEGAsyncCompleteEvent.JPEGASYN C_COMPLETE,arguments.callee);
      });
      encoder.encode(bd);
      ====================================
      function encodeDone(e,lastid,propid)
      {
      var photosdir = air.File.applicationStorageDirectory.resolvePath("photos");
      var myFile = new air.File(photosdir.nativePath+ "/" + lastid +".jpg");
      var myFileStream = new air.FileStream();
      myFileStream.addEventListener(air.Event.CLOSE, function(e){
      customsaveEventCounter= customsaveEventCounter+1;
      if (customsaveEventCounter == customsaveEvent) {
      synchphotos();
      customsaveEventCounter =0;
      customsaveEvent=-1;
      }
      myFileStream.removeEventListener(air.Event.CLOSE,arguments.callee);
      });
      myFileStream.openAsync(myFile, air.FileMode.WRITE);
      myFileStream.writeBytes(e.ImageData);
      myFileStream.close();
      }
      ==================================================
      any ideas what could be the reason ??