Android Performance Metric Part 1

Anil Gudigar
3 min readJul 23, 2018

--

An App is considered to have poor performance when it responds slowly and freezes crashes or consumes lots of battery power.to avoid these issues we can use some tools that will help make the app crash-free and memory leak-free and get lots of performance metrics.

Performance metrics: These IT measures focus on how the user is experiencing the app.

Let’s list different kinds of performance metrics we should be concentrate on before app release to play store

1. Memory Managment.

App memory management would be the major metric we should be looking at before an app module or feature gets released in development release or production release. memory leaks that cause OutOfMemoryError to crash in our apps at some point, sometimes even in production.

Square’s Pierre-Yves Ricau solved this problem by building LeakCanary, a tool to detect and help you fix memory leaks before they ship.

before getting into LeakCanary we should read through this blog, which will give a good insight into how to read the HPROF file ( memory dump) created when a memory leak occurs.

https://android-developers.googleblog.com/2011/03/memory-analysis-for-android.html

To Integration LeakyCanary to Application please follow the below steps.

Edit your application module’s build. gradle to add the following dependencies.

Setup LeakCanary at your Application class.

to detect memory leaks for all activities we need to add RefWatcher in activity class.

A sample leaking Activity will look like below.

please find SingletonSavesContext below.

For fragments, it’s recommended to add RefWatcher.

We can see all the leaks in the list with timestamps.

.

.

we can see the memory dump details and also share heap dump to google drive or over email.

we can fix the memory leak issue before we publish the application into the Play Store with the use of a leaky canary.

I will continue with the next performance metrics in part 2.

Originally published at http://androidtechieblog.wordpress.com on July 23, 2018.

--

--

No responses yet