9 ways to avoid memory leaks in Android

9 ways to avoid memory leaks in Android

A memory leak happens when memory is allocated but never freed. This means the garbage collector is not able to take out the trash once we are done with the takeout. Initially, this might not be a problem. But imagine if you don’t take the trash out for 2 weeks! The house starts to smell right?

Similarly, as the user keeps on using our app, the memory also keeps on increasing and if the memory leaks are not plugged, then the unused memory cannot be freed up by the Garbage Collection. So the memory of our app will constantly increase until no more memory can be allocated to our app, leading to OutOfMemoryError which ultimately crashes the app.

So what are some of the common mistakes that lead to memory leaks?


要查看或添加评论,请登录

Anastasiya Liverant的更多文章

社区洞察

其他会员也浏览了