Yes, I'm facing the exact same problem. It looks like a bug in AudioTrack. For me the GREF count seems to increase by 2 for every creation and use of AudioTrack, and it never goes down. I do not see this problem when instead creating and using MediaPlayer (and writing synthesized sound to flash memory), supporting the conclusion that the problem lies with AudioTrack.
Thanks On Jun 27, 5:59 pm, Morné Pistorius <mpistor...@gmail.com> wrote: > Hi all, > > If I create and release multiple AudioTrack objects, theGREFcount > continually increases which eventually causes an application crash. > This small test code snipped illustrates the problem: > > byte[] buffer = readAudioFile( "audio.raw" ); > for ( int n = 0; n < 10; ++n ) > { > for ( int i = 0; i < 100; ++i ) > { > Log.v("Info", "Track " + n + "," + i ); > AudioTrack newTrack = new AudioTrack > ( AudioManager.STREAM_MUSIC, 16000, > > AudioFormat.CHANNEL_CONFIGURATION_MONO, > > AudioFormat.ENCODING_PCM_16BIT, > > buffer.length, AudioTrack.MODE_STATIC ); > > newTrack.write( buffer, 0, buffer.length ); > newTrack.flush(); > newTrack.release(); > } > > Runtime.getRuntime().gc(); > } > > Even with a forced garbage collection, I end up with the same highGREFcount > at the end of the loop. In my application, I continuously > create AudioTracks from variable lenght buffers. I guess I can try > and use a fixed size pool of AudioTracks each with a buffer large > enough to fit my longest sound, and try and reuse them. Is there a > better/correct way to completely clear resources used by an > AudioTrack? > > Any help will be greatly appreciated, > Thanks! > Morne --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---