admob causes memory leaks issue

Skip to first unread message


Aug 14, 2011, 6:09:37 PM8/14/11
to Google AdMob Ads Developers
I'd implement AdMob in my android app using 4.1.1 SDK and i'd
eventually discovered that it causes memory leaks. Moreover it somehow
stores the current state of RAM usage and restore it on the next run.
That is if due to the leaks my app starts to allocate 30 megs of RAM
instead of 12 as it takes at very 1st run it will take more than 30
megs on the next app's run. And this weird caching causes the app to
crash after a few runs.
Admob implemented in following way:

private void initAdMob(){
if (isFinishing())

// Lookup R.layout.main
final LinearLayout layout =

// Create the adView
adView = new AdView(this, AdSize.BANNER,

// Add the adView to it

// Initiate a generic request to load it with an ad
final AdRequest adRequest = new AdRequest();



this method called from my activity onCreate(). Also i had the
following in my overridden finish():

public void finish() {

if (adView!=null){

link to adview is declared in same activity:

private AdView adView;

my activity maintains the service. but when activity is no longer run
(finished) my service to which my activity binds/unbinds still
allocates more memory than it has to. That is if i dont call initAdMob
my service takes only 7Mb. when i do call initAdmob my service takes
12-13Mb. It doubles for nothing!!! No GUI - no way to show any ads -
so why is it still persist and takes 7mb of RAM?

And the second problem is my app grows in RAM 2fast if i rotate the
device while ads are showing. Every orientation change adds 1-3Mb!!!
30-40 changes = crash! And since it keeps the amount of RAM usage from
start to start things goes too bad...


Aug 15, 2011, 11:32:00 AM8/15/11
to Google AdMob Ads Developers
Use the eclipse memory analyizer to determine who is holding on to
memory. I have had memory leak issues with admob in the past but I
haven't seen any with the current SDK. YMMV.


Aug 15, 2011, 1:31:07 PM8/15/11
i tried to use it but got no result. I made the app to crash and it allocated about 60 megs of RAM. But MAN shows me info on approx. 2 Mb only. I didn't get where the rest leaked memo shows in MAN...


Aug 16, 2011, 8:42:59 AM8/16/11
I've discovered that my "RAM allocating/caching" issue is related to the fact that AdMob doen't let my app to finish properly. When my activity and service are both finished AdMob stays in RAM 4ever and moreover - it continues to send HTTP requests!
This makes me to use System.exit(0) and AdMob shutdowns only in this way which is inappropriate. I don't like to use System.exit(0) but seems like there is no other way...

Johnny Zen

Sep 1, 2011, 4:29:35 PM9/1/11
We are experiencing same memory leaks, and app grows upto 60mb. Looking at heap dumps, noticing a lot of bitmap allocations.

Johnny Zen

Sep 1, 2011, 4:30:48 PM9/1/11
gonna test a workaround where we search the ad viewgroup and remove bitmaps during onDestroy. Will post if helps.


Sep 6, 2011, 10:17:20 AM9/6/11
to Google AdMob Ads Developers
Did you manage to test your work-around? I'd be interested if it can
help as I just reproduced the memory leak, loosing 512KBytes each time
an adview is added/removed from an activity!!!

Valerian Teritron

Jan 10, 2016, 6:05:28 AM1/10/16
to Google Mobile Ads SDK Developers,

Google and AdMob is ridiculous! Its now 2016 and they are not able to solve this.

It tried to integrade AdMob (interstitial) in my app/game. But the AdMob framework seems to be programmed by students of the first semester. Why? Because I can not add AdMob to my app/game, because after loading the ad, my app consumed additional 28 MB memory. It is even not freeing the space, so the next ad load(s) increase the memory until there is no memory at all. At budget phones this happens fast. Sorry I have to look for a more lightweight ad framework. Argghhh

Imaging that an ad is nothing else then a picture/bitmap, and if you click on that you are forwarded to the system browser. Can you believe a code that needs 28 MB to display a plain bitmap on screen? How many fools must have coded here around to provide such a poor solution. As developer we could do this much better on our own, if google/admob provides us an url the fetch the image to show ourselfs, and tells us the url with which we shall open the browser.

Vu Chau (MobileAds SDK Team)

Jan 11, 2016, 10:05:56 AM1/11/16
to Google Mobile Ads SDK Developers,
Hi Valerian,

Thanks for the feedback, but we'd like to reiterate a few key points here just so we are on the same page.  Normally WebViews are themselves expensive without the additional CSS and JavaScript of the creatives.  If you feel an abnormally big amount of resources is being consumed, you could temporarily halt the operations of these WebViews either via onPause() or pauseTimers().  Speaking of the creatives, while the SDK does not have controls of the properties of these creatives per se (e.g. size and animation), you have the choice of ad networks from which to request for ads.  If you use a web proxy tool, like Charles, you should be able to tell where a creative comes from (if not AdMob, and if mediation is enabled).  You can then disable that network from serving.  Keep in mind that the SDK itself is pretty lightweight, but the interstitials can be heavy, especially so with video interstitials.  The 28 MB would seem to be coming from the size of the creative itself.

Speaking of the leak, are you able to obtain and provide us a trace that shows the leak?  Over time, as more and more interstitials are processed, the SDK will perform internal memory cleanups automatically to stabilize the memory, so seeing memory usages spiked long-term would be abnormal.


Vu Chau
Mobile Ads SDK Team
Reply all
Reply to author
0 new messages