Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ADMOB Memory Leaking?

Tags:

I'm using Swift language for ADMOB whenever new advertisement comes up, my Memory is increasing. I think there is a Leaking. Without ADMOB everything else is fine.

var inter: GADInterstitial   override func viewWillAppear(animated: Bool) {     inter = GADInterstitial()     inter.delegate = self     inter.adUnitID = "****"     var request:GADRequest = GADRequest()     request.testDevices = [ "***" ]     inter.loadRequest(request) } 

And I'm using UIActionAlert for displaying the Interstitial

self.inter.presentFromRootViewController(self) 

Memory Report Link:

https://www.dropbox.com/s/zjkt2f38rcy1ryr/Screenshot%202014-07-27%2020.17.18.png

Am I doing something wrong? I'm using ARC. Can I force to release this Interstitials by myself.

EDİT:

I tried GADBanner too. I'm just opening the app; I'm not doing anything else and memory is increasing

override func viewWillAppear(animated: Bool) {  banner = GADBannerView()  banner.delegate = self  banner.adSize = kGADAdSizeSmartBannerPortrait  banner.adUnitID = "****"  var request:GADRequest = GADRequest()  banner.rootViewController = self  request.testDevices = [ "****" ]     self.view.addSubview(banner) } 

https://www.dropbox.com/s/3gn3pq3s1w2gfdd/Screenshot%202014-07-27%2022.05.51.png

like image 473
Kerim Doruk Akıncı Avatar asked Jul 27 '14 17:07

Kerim Doruk Akıncı


2 Answers

You need to call destroy() to avoid memory leaks on both banner and interstitial ads. Interstitial ads are one-time-use objects, so you would have to destroy them. Banner ads can be reused but once done using them, call destroy().

See this for reference.

like image 69
amigo_2627 Avatar answered Sep 19 '22 15:09

amigo_2627


I had the same issue, although with GADInterstitial AdMob ads. HUGE CPU churn from the memory leak. The problem is that you have to go to your actual root view controller. I'm in Objective C, but basically, if you're in, say, a UITabBarController view hierarchy, then try this:

banner.rootViewController = (UITabBarController *)self.view.window.rootViewController 

That one thing solved all of my issues. Hope it works!

like image 23
Mike Critchley Avatar answered Sep 18 '22 15:09

Mike Critchley