[For Developers] LeakCanary By Square Is Really A Low-Effort Library For Easily Tracking Lower Memory Leaks In Android Apps
Writing great, high-quality software packages are effort. It doesn’t matter how we all know a platform or how extended we purchase code, there will probably be bugs. Memory leaks are signs problems, and they might be particularly disruptive on mobile phones. Square tried to make memory leaks better to find and fasten having a completely new library referred to as LeakCanary. It will make leak recognition almost automatic and presents results in both logcat and a straightforward-to-read interface.
LeakCanary is built to be as easy to use as you can. For a lot of applications, it must just have a few additional lines inside the app’s build.gradle file, then one more kind of code within your Application class. This will enable tracking for memory leaks in activities. For further comprehensive coverage, the RefWatcher object might be given to observe objects that should be garbage collected.
When a product isn’t released properly, LeakCanary publishes a leak trace to logcat and fosters a notification inside the status bar. Tapping round the notification reveals a screen getting an easy demonstration of the leak trace that shows which class object remains holding a reference. If memory leaks are identified that cannot be fixed, including known issues inside the Android SDK itself, LeakCanary might be configured to disregard these without producing any notifications.
Solutions are temporarily locked in your app’s private storage, but they might be exported using a share intent, or they might be posted with a server with a few extra code.
LeakCanary joins Square’s substantial report on free projects. It’s completely free as well as the member list was already exploding in proportions. For a short while of backstory about how precisely the job began, check out Square’s blog publish, or dive towards the setup instructions to acquire started from it inside your projects.