2 Replies Latest reply on Feb 9, 2010 10:22 AM by Joe ... Ward

    Memory optimization

    Tibor Szasz

      Hello dear AIR users,

       

         I've encountered a problem that seems to be a bit tricky to solve  I'm creating an application based on HTML+JS, that streams music from the web, mainly long mixes and big tracks. When I start to stream a new song, the old one stays in memory, and soon it exceeds a couple hundreds of mbytes.

       

      Is there any method, technique to free them up?

       

      This is the part that streams the files:

       

           streamFile: function( url ) 
           {
                var pass = this;
                if( this.soundbase !== false )
                {
                     // Stop stream
                     if( this.stream_progress < 100 ) 
                     {
                          this.soundbase.close();
                     }
                     // Stop playback
                     this.stop();
                } 
                CD.GUI.setStatusMessage('Streaming...');
                this.soundbase = new air.Sound();
                this.soundbase.addEventListener(air.ProgressEvent.PROGRESS, function( event )
                {
                     pass.stream_progress = Math.round( 100 * ( event.bytesLoaded / event.bytesTotal ) );               
                });
                this.soundbase.load( new air.URLRequest( url ) );
                this.channel = this.soundbase.play();
           },