Android Admob 4.1.1 has a memory leak (see attached test project). Cause/fix/work around?

My app uses 80% of the allowed 16Mb and the AdView leaks at every orientation change (since android destroys and recreates the whole activity then). As a result I am out of memory after a dozen or so orientation changes giving me the dreaded: 10-08 10:14:47.178: ERROR/dalvikvm-heap(2876): 1440000-byte external allocation too large for this process 10-08 10:14:47.178: ERROR/dalvikvm(2876): Out of memory: Heap Size=5191KB, Allocated=2877KB, Bitmap Size=18675KB 10-08 10:14:47.178: ERROR/GraphicsJNI(2876): VM won't let us allocate 1440000 bytes or similar The increase in memory can easily be seen in eclipse by doing a debug run and opening Window > Open perspective > Other > DDMS, clicking the "update heap" icon and doing a Cause GC. The easiest way to check imho is the #Objects.

If the orientation has changed from portrait to landscape and back, the number of Objects should be exactly the same (and without AdView it is) I work around the memory leak by making the AdView static private static AdView mAdView = null; @Override public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); if(mAdView == null) { mAdView = new AdView(this, AdSize. BANNER, ADMOB_PUBLISHER_ID); } } and not calling the destroy Override public void onDestroy() { super.onDestroy(); //mAdView.

DestroyDrawingCache(); //mAdView.destroy(); //mAdView = null; } At least this prevents memory leaks between every orientation change Also I set request to null after using it. Don't know if that helps AdRequest request = new AdRequest(); mAdView. LoadAd(request); request = null.

My app uses 80% of the allowed 16Mb and the AdView leaks at every orientation change (since android destroys and recreates the whole activity then). As a result I am out of memory after a dozen or so orientation changes giving me the dreaded: 10-08 10:14:47.178: ERROR/dalvikvm-heap(2876): 1440000-byte external allocation too large for this process. 10-08 10:14:47.178: ERROR/dalvikvm(2876): Out of memory: Heap Size=5191KB, Allocated=2877KB, Bitmap Size=18675KB 10-08 10:14:47.178: ERROR/GraphicsJNI(2876): VM won't let us allocate 1440000 bytes or similar.

The increase in memory can easily be seen in eclipse by doing a debug run and opening Window > Open perspective > Other > DDMS, clicking the "update heap" icon and doing a Cause GC. The easiest way to check imho is the #Objects. If the orientation has changed from portrait to landscape and back, the number of Objects should be exactly the same (and without AdView it is).

I work around the memory leak by making the AdView static private static AdView mAdView = null; @Override public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); if(mAdView == null) { mAdView = new AdView(this, AdSize. BANNER, ADMOB_PUBLISHER_ID); } } and not calling the destroy @Override public void onDestroy() { super.onDestroy(); //mAdView.

DestroyDrawingCache(); //mAdView.destroy(); //mAdView = null; } At least this prevents memory leaks between every orientation change. Also I set request to null after using it. Don't know if that helps.

AdRequest request = new AdRequest(); mAdView. LoadAd(request); request = null.

I created a LinearLayout to hold the AdView and proceeded as you did and there were no more leaks, but the ads were not clickable either and it was a bit of a pain detatching the static AdView from the previous views before it could be reused. – timothyjc Oct 9 at 19:27.

Yes, I build it all up dynamically. I use removeAllViews to remove all views from my (LinearLayout) container. Then I use addView to put them all back again.

The ad is clickable. Is there perhaps some transparent view in front of it in your case?

I have a test project which demonstrates a memory leak caused by Admob 4.1.1. The basic scenario is I have two activities and I switch back and forth between the main and the sub activity several times. I then switch to DDMS and force a few GCs.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions