ADMOB内存泄漏? [英] ADMOB Memory Leaking?

查看:245
本文介绍了ADMOB内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当新广告出现时我都会使用Swift语言进行ADMOB,我的内存正在增加。我觉得有一个漏洞。没有ADMOB其他一切都没问题。

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)
}

我正在使用UIActionAlert显示非页内广告

And I'm using UIActionAlert for displaying the Interstitial

self.inter.presentFromRootViewController(self)

内存报告链接:

我做错了什么?我正在使用ARC。我可以强制自行释放此插页式广告

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

EDİT

我也试过 GADBanner 。我只是打开应用程序;我没有做任何事情,内存正在增加

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)
}

推荐答案

你需要打电话 destroy()以避免横幅广告和插页式广告上的内存泄漏。非页内广告是一次性使用的对象,因此您必须销毁它们。横幅广告可以重复使用,但一旦使用它们,请致电 destroy()

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().

请参阅此参考

这篇关于ADMOB内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆