Leakcanary, a sharp tool for Android memory leak troubleshooting

This article shares the Android memory leak troubleshooting tool for your reference. The specific contents are as follows

Open source address: https://github.com/square/leakcanary

Add dependencies in build.grade, and then sync. The addition is as follows

Ellipsis stands for other existing content

Initialize leakcanary in the application class.. For example, it is called myapplication. If not, create one and inherit android.app.application. Don't forget to add in androidmanifest.xml, otherwise it won't work

The official has a demo. You can run and see it.

Enter the main interface, press the button, and then press the return key to exit the main interface. Repeat several times, and leakcanary can detect the memory leak. Be careful to operate several times. Once, the leakage scale is too small and may not be detected. Once leakcanary is detected, a prompt will pop up.

Back on the desktop, you will see a leakcanary icon. If multiple apps are used, there will be multiple leakcanary icons.

Click in to see the memory leak record

Click in again to see the call stack

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

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
分享
二维码
< <上一篇
下一篇>>