Android avoids memory leaks

That is, the recycled memory is not recycled for various reasons and still resides in the memory.

Maybe a small memory leak will cause the whole application to jam or even crash.

This code may have a memory leak.

If the toast holds the current activity before the toast disappears, and the user clicks the return key, the activity cannot be recycled by GC (garbage collection garbage collection), and the activity will cause memory leakage.

All contexts unrelated to the current activity can be passed in. The method to avoid memory leakage also uses other places where context needs to be passed in. I can't understand this sentence

Getapplicationcontext () is the context of the whole application and will not hold an activity object.

The context of dialog cannot use getapplicationcontext (). The program will crash. The instantiation of dialog must hold the activity object.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>