Memory leak using AdMediator with pubCenter and AdMob RRS feed

  • Question

  • Hello,

    I'm using the latest version of AdMediator in my Silverlight Windows Phone 8.0 application.

    I'm using it with Google AdMob and Microsoft pubCenter.

    I've noticed that, when I navigate to other pages, AdMediatorControl doesn't release its memory, in fact after 10~15 navigations (depending on how many ads I put on the pages) the application crashes with an OutOfMemoryException.

    If I remove the AdMediatorControl from the XAML this doesn't happen and the memory is correctly released (I can see it in Windows Phone Developer Power Tools).

    I tried to set my AdMediatorControl instance to null on the event OnNavigatedFrom but this doesn't change anything.

    I can't publish my app because of this. Could you please help me?

    Monday, February 1, 2016 10:21 AM


  • Solved! I just had to use the same instance for the whole app.

    Here's how I solved the issue:

    I've removed AdMediator and instantiated the banners manually using C#. So, I've created a single instance of AdView and AdRequest (public static) in the class App which I initialize in the event Application_Launching.

    Then, in every page where I needed a banner, in the event OnNavigatedTo I set the AdView of App class as a children of the page Grid (ContentGrid) and launch the LoadAd method on the AdRequest instance of the App class.

    Then, in the event OnNavigatedFrom, I remove the AdView from the Children of the Grid.

    Done! No more memory leak! :D

    • Marked as answer by No Else Monday, February 1, 2016 12:23 PM
    Monday, February 1, 2016 12:22 PM