Garbage Collection causes : MediaPlayer finalized without being released
I think this is because you create the media player within the scope of the method, therefore, when the method completes, it goes out of scope. This means there are no references, so is ok for garbage collection.
This means, it can be free'd by the GC before it has even called onCompletion, hence won't release before cleared. Instead, you need to store a reference to the media player as a member variable in your class.
MediaPlayer in Async Task : finalized without being released
Problem fixed. Thanks to the poor code by other developers. Thank you everyone here.
How to check what prevents an object from being eligble for garbage collection?
Quoting the documentation:
When you see something suspicious, right-click on the item and select Path To GC Roots > exclude weak references. This opens a new tab that traces the references to that object which is causing the alleged leak.
You may also be interested in Patrick Duboy's Google I|O 2011 presentation on this topic. Here are the slides and the video.
Related Topics
Wrong Fragment in Viewpager Receives Oncontextitemselected Call
Android: How to Get Current Opened Application Name on Screen
Handling Keepsynced() While on Background on Android and with Fcm
Properly Using Asynctask Get()
Progress Bar While Loading Image Using Glide
Loading All the Images from Gallery into the Application in Android
Existing 3-Function Callback to Kotlin Coroutines
How to Implement Google Maps Search by Address in Android
Android Downloadmanager Progress
How to Detect Android CPU Speed
Realm with Pre Populated Data into Assets
Cannot Resolve Mapactivity Class on Android
How to Calculate Phone's Movement in the Vertical Direction from Rest
How to Solve Nullpointerexception Error in Android
How to Deal with Different Aspect Ratios in Libgdx