iOS AdMob memory leak?

前端 未结 1 1248
陌清茗
陌清茗 2021-02-10 04:23

I just started using AdMob but I noticed that, after running it for about an hour, it\'s accumulated 50MB! Yikes. I thought about releasing it but I can\'t since I

1条回答
  •  [愿得一人]
    2021-02-10 04:58

    I had the same problem.

    When receiving a new ad, you must remove the previous ad from the parent view.

    Otherwise, they are superimposed on each other and consumes memory.

    So, after receiving more than 15 advertisements, the percentage of allocated memory remained constant.

    Hoping that this will help you.

    - ( void )displayBanner:( UIView * )banner
    {    
        UIView * oldBanner = [ _bannerView viewWithTag:999 ];
    
        if( oldBanner )
        {
           [ oldBanner removeFromSuperview ];
           oldBanner = nil;
        }
    
        banner.tag = 999;
        [ _bannerView addSubview:banner ];
    }
    

    0 讨论(0)
提交回复
热议问题