0 Replies Latest reply on Jun 15, 2010 4:01 AM by BjarteNorway

    Memory leak problems with loading videos over and over.

    BjarteNorway

      I'm having memory leak problems with loading videos into a VideoPlayer aswell as FLVPlayback.


      What the flash should do:

      - Should be running for 7 days without having to restart the projector.
      - Interface that shows people around a 360 3D model with 5 different parts and at the stops it makes during the rotation you can click to zoom in on a location which plays a movie for that aswell.
      - Shows a video out of 5 parts for a 360 rotation in 3D in mp4 video (added each time and cleaned up, see code below).
      - Still images are used when the video clips are done playing (MovieClip in stage).

      - Should run automatically when there is no user interaction for X minutes.

       

      What the problem is:
      - The flash (as a exe and swf i guess) starts to consume memory over time (say 10 hours) until the projector crashes. This usually at around 1.75 GB of memory.
      I cannot see why the Flash cannot garbage collect this and free up the memory. Mabye there is something I don't understand about the garbage collection in flash?

       

      Here is some code from the video loading and playing:

       

       

      var fVideo:VideoPlayer;
      
      VideoCreate();
      
      function VideoReady(pEvent:VideoEvent):void
      {
           
      trace("VideoReady()");
           
           // start playing video
           
      fVideo.play();
      }
      
      function VideoLoad(pUrl:String):void
      {
           trace("VideoLoad(" + pUrl + 
      ")");
           
           VideoCreate();
           
           if (pUrl != "")
           
      {
                if (fVideoFolder + pUrl == fVideo.source)
                
      {
                     fVideo.seek(0);
                     
      VideoReady(null);
                     
                } else {
                     
      trace(fVideo.state);
                     if (fVideo.state != 
      VideoState.DISCONNECTED) fVideo.stop();
                     
      fVideo.close();                                 
                     
      fVideo.load(fVideoFolder + pUrl);
                }
           } else {
                
      // error no url
           }
      }
      
      function VideoCreate():void
      {
           trace("VideoCreate()");
      
           // remove old one
           if (getChildAt(0) == fVideo)
           
      {
                removeChildAt(0);
           }
           
           fVideo = new 
      VideoPlayer(1024, 768);
           addChildAt(fVideo, 0);
      
           fVideo.autoRewind = false;
           
      fVideo.addEventListener(VideoEvent.COMPLETE, VideoDonePlaying);
           
      fVideo.addEventListener(VideoEvent.READY, VideoReady);
      }