Skip to content

Memory Leak? #30

@starburst997

Description

@starburst997

Memory usage is steadily increasing over time

    public class Test4 extends Sprite
    {
        public function Test4()
        {
            stage.frameRate = 0xFFFF;
            addEventListener( Event.ENTER_FRAME, ef );
        }

        public var lastPlayer:AudioPlayer;
        public function ef( event:Event ):void
        {
            if ( lastPlayer != null )
            {
                lastPlayer.stop();
            }

            var source:IAudioSource = new SineSource(new AudioDescriptor( 44100, 2 ), 5, 440);
            var player:AudioPlayer = new AudioPlayer();
            player.play(source);   // actually make some noise

            lastPlayer = player;

            trace(Number(System.totalMemory/1024/1024).toFixed(2), Number(Sample.getAwaveMemoryUsage() / 1024 / 1024).toFixed(2));
        }
    }

Am I doing something wrong here? It is also leaking even if you play it one time, the "New" at each frame is to better show the increase.The only way I was able to fix it was to use Flash built-in "writeBytes" instead of "awave.writeBytes"

If I look at the Profiler, the ByteArrays stay in memory. A workaround:

On line 850 in "Sample.as" replace

Sample._awave.writeBytes(getSamplePointer(offset), destBytes, _descriptor.channels, numFrames);

with

destBytes.writeBytes( _awaveMemory, getSamplePointer(offset), numFrames * _descriptor.channels * 4 );

Now when I look at the profiler, it isn't leaking anymore.

I tried to play with "awave.c" using an old Alchemy toolchain since it doesn't seem to be compatible with Flascc but couldn't find a proper fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions