Skip to content Skip to sidebar Skip to footer

Prevent Memory Leak In Android

I'm having some troubles with memory leaks on Android. I do have a simple application with a relatively picture as background and it works fine, until I change the orientation.

Solution 1:

You could try to avoid reload your activity with this in your manifest under your activity:

android:configChanges="orientation|screenSize"

Solution 2:

I've managed to solve the problem. It was all because of a damn timer which was setting a tick event on every screen orientation change. To fix the issue I simply binded the timer to a variable, and called timer.cancel() in onSaveInstance()

Now my memory leaks are gone (as shown below): no more memory leaks

Post a Comment for "Prevent Memory Leak In Android"