Hi all, If I create and release multiple AudioTrack objects, the GREF count 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 high GREF count 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 -~----------~----~----~----~------~----~------~--~---