Looking to the code, I can't find any possible root cause for this leak.

Are you sure the GC was executed before you take the heap dump? You can
force it using DDMS.

Also, using MAT (eclipse.org/mat) you can identify who is retaining a
reference to the LeakyActivy object.

Felipe Silveira
http://www.felipesilveira.com.br

On Wed, Apr 14, 2010 at 10:37 AM, Joshua Frank <[email protected]>wrote:

> I am using a simple frame animation and when I exit and reenter my
> activity the activity is still referenced in memory. Any Ideas?
>
> //This is a sample activity I created to simulate the problem
> public class MemoryLeakActivity extends Activity {
>
>    @Override
>    public void onCreate(final Bundle savedInstanceState) {
>        super.onCreate(savedInstanceState);
>    }
>
>    @Override
>        public boolean onKeyDown(final int keyCode, final KeyEvent event) {
>        final Intent i = new Intent(MemoryLeakActivity.this,
> LeakyActivy.class);
>        startActivity(i);
>                return super.onKeyDown(keyCode, event);
>        }
> }
>
> //This is the activity that runs the frame animation
> public class LeakyActivy extends Activity {
>
>        AnimationDrawable frameAnimation;
>
>        @Override
>        protected void onCreate(final Bundle savedInstanceState) {
>                super.onCreate(savedInstanceState);
>
>                setContentView(R.layout.main);
>
>                final View v = findViewById(R.id.main);
>
>                v.setBackgroundResource(R.drawable.awe);
>
>                frameAnimation = (AnimationDrawable) v.getBackground();
>
>        }
>
>        @Override
>        public boolean onKeyDown(final int keyCode, final KeyEvent event) {
>                frameAnimation.start();
>                return super.onKeyDown(keyCode, event);
>        }
>
> }
>
>
> If I start LeakyActivity then hit the back button then start
> LeakyActivity again it stays in memory. I know this because I have
> been dumping the HPROF files.
>
> --
> Joshua Frank
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
> To unsubscribe, reply using "remove me" as the subject.
>



-- 
Felipe Silveira
Engenharia da Computação
Universidade Federal de Itajubá
http://www.felipesilveira.com.br
MSN: [email protected]
-------------------------------------------------

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to