5 Replies Latest reply on Oct 3, 2011 8:25 AM by paparachan

    Memory leak. How to unload video explicitly?

    S_Aleksey Level 1

      I have OSMF version 1.6 and use Flex 4.5 SDK. I have created very simple test:

      <?xml version="1.0" encoding="utf-8"?>

      <s:WindowedApplication width="900" height="800" xmlns:fx="http://ns.adobe.com/mxml/2009"

      xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx">



      import org.osmf.containers.MediaContainer;

      import org.osmf.elements.VideoElement;

      import org.osmf.media.MediaPlayer;

      import org.osmf.media.URLResource;


      private var mediaPlayer:MediaPlayer;

      private var container:MediaContainer;

      private var media:VideoElement;



      public function play():void


      var file:File = new File("D:\\testAssets\\test.flv");





      mediaPlayer.media = null;


      media = new VideoElement( new URLResource(file.url));

      mediaPlayer = new MediaPlayer();

      mediaPlayer.media = media;

      container = new MediaContainer();

      container.addMediaElement( media );

      videoContainer.addChild( container );





      <mx:UIComponent y="40" id="videoContainer">



      <s:Button label="Play" click="play()"/>



      When you quickly press Play button several times(around 12-15 for me) then application just crashes(debugger stops to work as well). I tried to profile application and seems like instances of MediaPlayer, VideoElement etc are collected by garbage collector. What is wrong with this example? Can I somehow unload video from memory explicitly?  


      Thanks, Aleksey