3 Replies Latest reply on Mar 22, 2010 4:22 PM by FTQuest

    Playing a Live Audio Stream: Memory leak issue, how to limit the buffer size ?

    POUSSIN Mathieu Level 1


      I have a little problem, I've made a simple media player (Flex/AIR powered, but the question isn't specific to AIR) to read a live stream that come from IceCast,

      The problem is, the memory usage grow grow grow grow too much (It never stop to grow...), any Idea of how can I stop this ? Can I limit the buffer size ?


      Here are some part of the code :




      [Bindable] public var loadedUrl:URLRequest;

      [Bindable] public var channel:SoundChannel;

      [Bindable] public var song:SoundAsset;

      [Bindable] public var songStatus:String = "";

      [Bindable] public var songTitle:String = "";

      [Bindable] public var songAlbum:String = "";

      [Bindable] public var songArtist:String = "";

      [Bindable] public var songPos:Number = 0;



      /** Function that load an URL for remote resource loading, then redirect to fileSelected */

      private function loadUrl():void {

      loadedUrl = new URLRequest(mediaUrlInput.text);





      /** Generic function called when loading a local or remote file, perform ID3 loading */

      private function fileSelected():void {

      if(songStatus=="Playing") {




      songPos = 0;

      song = new SoundAsset()

      song.addEventListener(Event.ID3, infoLoaded);





      /** Play function of the player, activate the channel and initialize and bind a sound transformer */

      private function play():void {


      channel = song.play(songPos);


      var songTransform:SoundTransform = new SoundTransform(volumeSlider.value);

      channel.soundTransform = songTransform;




      /** Pause function of the player, save the position in songPos then stop the channel */

      private function pause():void {

      if(songStatus=="Playing") {

      songPos = channel.position;







      /** Stop function of the player, stop the channel and set songPos to 0 */

      private function stop():void {

      if(songStatus!="Stopped") {


      songPos = 0









      (I removed the useless lines (ID3 loading, volume slider binding, etc) on this paste.

      Any idea of how can I fix it ?

      Thank you !