Using Eclipse Memory Analyzer i discovered that if I go back and forth between 2 activity (e.g. A and B), although onDestroy method of activity B is called, GC never removes it from memory, so I have multiple instances of Activity B in memory. I found that the problem is in initialize method called on YouTubePlayerFragment instance. Here is the code:
YouTubePlayerFragment ytpf =(YouTubePlayerFragment) getFragmentManager().findFragmentById(R.id.youtube_fragment);
ytpf.initialize(DEVELOPER_KEY,this);
this
is the the activity where fragment takes place, and implements YouTubePlayer.OnInitializedListener
.
How can I release the callback passed on initialize method?
I tried to call youtubePlayer.release()
but the problem remains.