Buy @ Amazon

Android - Don't Keep Activities - Developer Options



"Don't Keep Activities" - are you aware of this must turn-on developer setting in your Android device?

Not sure about you. The first time I saw this in the developer setting, I laughed out wondering why on earth a developer would want to do this, assuming that this would hide the app performance issues.

I was so damn wrong. Contrary to my assumption, turning on this developer setting actually helps you identify performance issues. It helps you identify memory leaks of an activity.

Where do I find this? See picture attached.

How it works? When the developer option - Don't Keep Activities - is checked-on, in the device, all activities that are stopped will be destroyed almost immediately. It simulates the Android Operating System behaviour when your app is in the background and the system is short on memory; because of which it will destroy your background activities.

How is it useful? It is intended to help developers debug their apps for testing saved instance states and detecting memory leaks. You have to use this in combination with LeakCanary, to help identify those dreaded memory leaks though. 

When to use it? Turn it on - always. If you find any unexpected behaviour of your app like freezes and force closures, it is a sign of bad code that requires fix.

References
1. Knowledge boost for junior Android developers — Part I
2. Don't keep activities - What is it for?