IOS AdMob memory error?

I just started using AdMob , but noticed that after starting it for about an hour, it accumulated 50 MB! Clap. I was thinking about a release, but I can’t, since I use ARC . Any ideas? I use the google code provided by google:

 GADBannerView *bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; CGRect newFrame = CGRectMake(self.scroller.frame.origin.x,self.scroller.frame.origin.y + 70,self.scroller.frame.size.width,self.scroller.frame.size.height); [self.scroller setFrame:newFrame]; bannerView_.adUnitID = @"XXXXX"; bannerView_.rootViewController = self; [bannerView_ setFrame:CGRectMake(0, 20, bannerView_.bounds.size.width, bannerView_.bounds.size.height)]; [self.view addSubview:bannerView_]; [bannerView_ loadRequest:[GADRequest request]]; 
+5
source share
1 answer

I had the same problem.

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

Otherwise, they overlap and consume memory.

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

Hope this helps you.

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

Source: https://habr.com/ru/post/1200718/


All Articles