Possible Memory Leak
Hello,
It looks like there is a memory leak in ExoPlayer. It is reproducible in our test suite on certain devices (Nexus 7 Android 4.4.3 for example). In about 30 tests (usually loads, plays and seeks) i'm seeing HlsSampleSource objects to stack up with large numbers of memory being held by them (5-20 megs each). This causes app to crash with OutOfMemoryException. We are doing proper release/destroy for ExoPlayer in our tests, and by looking at heap dump it looks like they are stacking up somewhere in ExoPlayer and has nothing to do to our code. Please see this screenshot and let me know if you would need full heapdump. http://imgur.com/zzec1YD
A screenshot without context isn't particularly helpful. What's that screenshot actually showing? Is it a path from GC roots, or something else? What version of ExoPlayer are you using?
@AquilesCanta fixed a resource leak in 1.5.4 (and later) in https://github.com/google/ExoPlayer/commit/c31473c5964a6f1faa75934d31d8b333e99e712c, so if you're using a version earlier than that please upgrade to 1.5.4 or later and try again.
Thanks!
This screenshot shows GC roots. We are using ExoPlayer 1.5.2, I'll try to upgrade soon and try again. Thanks!
So i've upgraded to ExoPlayer 1.5.5 and running the same tests on the same device and seeing the same issue. Path from GC roots for HlsSampleSource are the same, the are still stacking up. Please let me know what additional info do you need. I would have to find out if can attach heapdump.
I can't reproduce a leak using the demo app. I tried playing a HLS video, exiting back to the list of samples, playing another HLS video and so on. If there were a leak, I'd expect it to reproduce in this case.
I think the most likely explanation is that your code is not calling ExoPlayer.release properly on each instance of the player. Calling this method will cause the thread that's acting as the GC root in the image you've provided to quit, and so the fact that it's still a GC root suggests that this hasn't been done.
Please re-open if you can reproduce this with the demo app or provide more information. Thanks!