O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Memory leaks

If a memory block that will not be used still has a reference pointing to it, it cannot be reclaimed by Garbage Collector, and thus it becomes a memory leak. Memory is taken; it cannot be used for other purposes but a developer has no use for it.

On Android, quite often it is possible to see leaked Activities, and this is a major source of memory leaks. It usually happens when there is a global (Application Scope) reference still pointing to an Activity Instance after the Activity has been destroyed (when onDestroy() was called). In such a case, the Activity object cannot be removed from the memory by the GC, and thus all the resources that the Activity was pointing to cannot be freed up as well.

This can easily add up to megabytes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required