google / ExoPlayer

An extensible media player for Android
Apache License 2.0
21.62k stars 6k forks source link

RequirementsWatcher is not stopped when DownloadManager is released #10541

Open ferhatparmak opened 1 year ago

ferhatparmak commented 1 year ago

When DownloadManager.release() is called, it doesn't seem stopping RequirementsWatcher which keeps some receivers registered and that would hold DownloadManager instance. Isn't this a memory leak?

Memory profiler after release() is called on DownloadManager: Screenshot 2022-08-22 at 14 02 20

marcbaechinger commented 1 year ago

Thanks for reporting! This looks like a bug to me indeed!

DownloadManager.release() documents that the manager must not be accessed after this method has been called. Hence we must make sure that release cleans up the resources once acquired which includes the RequirementsWatcher that is created in the constructor (or on setRequirements(Requirements requirements) being called).

I think we need to call requirementsWatcher.stop() in DownloadManager.release() which unregisters the receivers.