Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6685291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:02:28+00:00 2026-05-26T05:02:28+00:00

I have a test project which demonstrates a memory leak caused by Admob 4.1.1.

  • 0

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. Then dump the HPROF and look at the historgram filtered by com.test* to see how many instances of the main and sub activity there are. My screenshots of the histogram are attached:

A leak!
leaks

I then commented out the ads in the xml and reran and there were no leaks:

No leak now
no leak

I have found some relevant posts to Admob leaks such as here: Android AdMob causes memory leak?

Here is a list of things I have tried to resolve the issue:

  1. Wait some amount of time and then force gc
  2. Do not load the ad in oncreate but spawn a thread to wait then load it
  3. Tried a previous version of Admob (the one not written by Google)
  4. Called adView.destroy() in the onDestroy() activity’s method
  5. The unbinding from this link

Obviously none of these things helped.

Here is the test project I wrote:

(Be sure to set your own publisher id when you run the test project)

download test leak android project

If it makes a difference I’m tesing on my SGS2 with Cyanogenmod ROM.

Does this happen for other people when they run this project?

Does anyone know the cause a fix or a workaround?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:02:29+00:00Added an answer on May 26, 2026 at 5:02 am

    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;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Django project which has two apps (one created as debug test).
I have to test some things on a project which has been developed by
I have two applications in my project 'test' the applications are one.mxml and two.mxml
I have a test project requiring some heavy jars which i put in ${M2_HOME}\test\src\main\resources\
I have two build definitions for my project which has two branches. Development and
I have simple test project which creates a frame and adds one JTextPane to
Using AdMob in MonoTouch Projects with iOS SDK 4.2 We have a test project
I have an Android test project in which I test my main application. The
I have a test project Company.Test which is located under C:\Dev\Projects\Tests folder When I
I have a test project in my appharbor solution which uses the connectionstring located

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.