Garbage Collection causes : MediaPlayer finalized without being released

前端 未结 2 500
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 08:01

After a lot of debugging I finally found what is causing this error! Garbage Collection!

I have a video playing in media view and in the background I am looking for

2条回答
  •  春和景丽
    2020-11-29 08:48

    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.

提交回复
热议问题