libgdx/libgdx — pull request #2206 by code-disaster (2014-08-05 15:51:08+00:00)
Title: Reuse heap and off-heap buffers when looping .ogg stream.

Hi,

in my crusade against all things heap & off-heap I noticed that each OggInputStream instance creates - amongst other things - a 2 MB off-heap buffer, even in case the music is just looping.

I'm not yet convinced that we aren't doing something wrong application-side (dangling references somewhere), but it looks like this memory isn't regained soon after. In my brief test with a short looping .ogg, the game's memory consumption did raise pretty much linearly.

Anyway, the PR just adds some code to reuse the buffers of the previous instance when the stream starts over. I didn't dare to do a more aggressive change, like reusing the whole OggInputStream instance. The largest memory consumption I'm now tracking is inside Jorbis - a can of worms I don't want to open right now. :)