How to detect memory leaks in Android
Updated: Dec 4, 2019
Memory leak is one of the most critical issues that can occur in an app. Fixing them is often challenging as the developer will not have access to the relevant data to identify the root cause. All that developer may get to see is an OutOfMemory (OOM) Exception with a stack trace that is of no practical use.
There are tools like LeakCanary for Android and XCode Leaks Instrument for iOS. These tools will help identify the leaks in the development environment. That is, if the developer proactively profiles the app for all possible use cases.
But what if the developer and the tester missed some use cases and there are leaks happening after the app has gone live? How will they know if leaks exist or not in live apps? Here is where Finotes becomes the developer's best friend as it can detect such issues in live apps and also during development and testing.
Finotes production mode Android SDK detects memory leaks in Android Activities and Services out of the box and reports the bugs to the dashboard with important data such as activity trail, device info and device state info. This will help developer to be aware of the leaks happening in their app that is running in their users' devices and also helps them to reproduce the memory leak.
Here is a screenshot of such a leak detected by Finotes in a live app.
Now the developer can use debug mode SDK of Finotes to drill down the issue further in the development environment. As seen in the below screenshot, debug mode SDK of Finotes will detect the exact object that is causing the leak.
As seen in the screenshot, the static object ProgressBarManager is causing the leak. With this object level information, it is much easier now for the developer to fix memory leaks.
Apart from memory leaks, Finotes detects API call issues, frame rate issues, abnormal memory usage, crashes, exceptions, function failures & delays. It also has the capability to report custom issues.
The memory leak detection is available in Finotes iOS framework as well. Read the blog article Detect memory leaks in iOS to understand know more.