How to detect abnormal memory usage and memory spikes in Android Apps
Updated: Sep 24
Memory management is one of the most crucial elements overlooked by developers during app development. Even while developing and testing features before the app release, memory profiling is often not done.
Abnormal memory usage pulls down app performance, which affects the user experience. If the app’s allocated memory gets exhausted, it can lead to an out of memory exception. Therefore, finding and fixing them at the earliest is important
Usually, Abnormal memory usage occurs because of inefficient object reuse or not reclaiming unused memory.
Finotes detects and reports abnormal memory usage and memory spikes. Integrating Finotes SDK to Android apps takes less than a minute. Visit the documentation page for detailed implementation details.
Tracking memory usage using Activity Trail
Whenever a spike in memory usage is detected, Finotes will report the corresponding issue with a list of events that occurred one minute prior to the issue occurrence. The app events, along with the percentage of free memory available at that point will be shown in chronological order.
Though Finotes records activity trail every time, it will be sent to the server only when an issue gets reported without creating any network overhead.
Components of an activity trail
The activity segment has details of the app events. The user event will have two components separated by a colon
The name of the class in which the event gets reported
The textual description of the event.
The timestamp segment has details related to the time at which the event gets recorded.
The memory segment also contains the percentage of free memory available for the app at the time of the event.
Let’s take a use case as indicated in the screenshot above. Here, Finotes has detected abnormal memory usage in an Android app. The issue is that the app’s memory usage jumped to 268435456 bytes which is more than 80 percent of the allocated memory.
Activity trail section in the issue report will help us to understand the reason for the issue better. The activity trail here indicates that the free memory while loading the first banner image was around 96%, but by the time last banner image was loaded, the free memory dipped down to almost 18%. On deep analysis, we understand that the reason for the dip in free memory is because the object allocated for the banner images was not released.
If this condition persists, it can lead to a crash. Finotes will detect and report whenever the app consumes more than an ideal amount of free memory before it leads to an app crash. The activity trail helps the developer to understand which events are causing the dip in free memory so that necessary changes can be made in the code, and a patch version can be released fast.
Custom Activity Trail Events
Apart from tracking default app events, Finotes provides developers with an API to set custom events ( See Java, Kotlin documentation) which can be called anywhere in the code. Such custom events recorded will be shown along with the default app events in the activity trail section in Finotes dashboard.
Apart from abnormal memory usage and spikes, Finotes detects memory leaks as well. Read more about that in our blog How to detect memory leaks in Android.
Apart from memory related issues, Finotes detects API call issues, frame rate issues, crashes, exceptions, function failures & delays. It also has the capability to report custom issues.