Android - Active References to Finished activity

      The most annoying memory usage for an android application is active references to finished activity and yet this is one of the most missed use cases and to make it worse the activity in turn could hold references to other application components and data structures effectively making it similar to its foreground version (in terms of memory usage). As a thumb rule, the dalvik heap after garbage collection shouldn't have any instances of the finished activity.

      A simple test is to finish all application components like activity by pressing back key and initiate a garbage collection via DDMS and then look for leaks in the heap snapshot.

No comments: