-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak #1855
Comments
I have upgraded my own project to ExoPlayer 2.0 and even calling player.release() does not release any resources. I am streaming mp4 files. After opening the player a second time with a mp4 file, it crashes with an OutOfMemory exception. |
Please can you provide more information on how this is reproduced in the ExoPlayer demo app? When I exit the playback activity and force 2x GCs via Android Monitor in Android Studio, the memory level reliably returns to its base level (I'm unsure why 2x GCs are required, but that's more likely a property of how the GC works than of ExoPlayer). Also, if you do multiple playbacks successively, does the memory level increase indefinitely? I would expect that to happen (eventually resulting in an OutOfMemory failure) if there were genuinely a leak. Please clarify. Thanks! |
Try simpleExoPlayerView.setPlayer(null); in your onDestroy() method. |
I am using an instance of SimpleExoPlayer without the SimpleExoPlayerView. The memory drops a little bit when opening the next instance of a player. After 3-4 times it crashes because of OutOfMemory. I have not tried the demo app, but thats how the memory graph looks in my application: The memory always increases, it never goes back. @Override
public void onDestroy() {
super.onDestroy();
releasePlayer();
}
private void releasePlayer() {
if (mPlayer != null) {
mPlayer.stop();
mPlayer.release();
mPlayer = null;
}
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
if (mPlayer != null) {
mPlayer.setVideoSurfaceHolder(null);
}
} Do i have to call something else? |
Please try with the demo app. Without further information, the memory leak you're seeing could be caused by anything in your application. A graph like the one above is not sufficient evidence the leak is ExoPlayer's fault. As long as you're releasing the player and nulling the reference to it, that should be sufficient. You should do it before |
This prevents a large amount of memory from being held in the case that a player instance is released, but the application is holding dangling references to the player that are preventing it from being garbage collected. Issue: #1855 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=134992945
We've pushed a change to Note however that you will only be experiencing this issue in the first place if you're leaking the player instance. We're unable to reproduce this problem in the demo app, and suspect that it's an issue in your own application code. You should work out where this leak is and fix it, since although our change will significantly reduce the size of the leak, the leak will still be there and you may be leaking other objects too. |
…layer is released. Without this developers which reuse a SurfaceHolder with multiple instances of SimpleExoPlayer need to call simpleExoPlayer.setVideoSurfaceHolder(null) to get the SimpleExoPlayer.ComponentListener removed from the surface holder. If they don't, the component listener is still registered and as a member class leaks an instance of simpleExoPlayer. Issue #1855 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135292439
I'm experiencing the same problem with ExoPlayer 2.0.0 in my own project. This app provides four buttons with four different dummy .mp4 files. In my opinion the player stops releasing memory after I included the controls. Could you please check my project and tell me where my problem is? |
Thanks for the very helpful reproduction steps. I've filed #1908 to track this issue. I'll also post a workaround there. |
Hi @PerkmannM , I am also facing the same issue with Google Media Framwork, It is internally using Exo Player 1.5.7. Could you please help me if you have resolved the issue as I couldn't track. |
The text was updated successfully, but these errors were encountered: