ios - Google Analytics iOS SDK 导致内存泄漏
问题描述
我正在使用通过 Cocoapods 安装的 Google Analytics iOS SDK v3.17.0。当应用程序打开时,我调试内存图。图中可见 32 个内存泄漏。如果我不初始化 Google Analytics,我不会在相同的情况下看到任何泄漏。
我搜索了下面的帖子,但没有包含特定问题并修复
https://github.com/firebase/quickstart-ios/issues/239
我如何初始化:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
//Window Properties
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
try! initGoogleAnalyticsManager()
let splashController = SplashViewController()
self.window?.rootViewController = splashController
return true
}
func initGoogleAnalyticsManager() throws{
guard let gai = GAI.sharedInstance() else {
assertionFailure("Google Analytics not configured correctly")
throw ServiceError.createCustomError(title: "Google Analytics Error", message: "Google Analytics Ayarlanamadı", type: ServiceError.ErrorType.ServiceError)
}
guard let trackingId = some value else {
assertionFailure("Google Analytics not configured correctly")
throw ServiceError.createCustomError(title: "Google Analytics Error", message: "Google Analytics Trackin ID Problem", type: ServiceError.ErrorType.ServiceError)
}
gai.tracker(withTrackingId: trackingId)
// Optional: automatically report uncaught exceptions.
gai.trackUncaughtExceptions = true
// Optional: set Logger to VERBOSE for debug information.
// Remove before app release.
#if DEBUG
gai.logger.logLevel = .verbose
#else
gai.logger.logLevel = .none
#endif
}
解决方案
推荐阅读
- python - 通过 API 从我的个人电报帐户发送消息
- python - 使用“createdb”将 Wagtail 站点部署到 Heroku 时连接被拒绝
- reactjs - 为什么 react-redux 将 store 传递给上下文?
- r - 标记库中的lookfor() 中出现重音字符或缺失值的错误?
- javascript - 如何正确键入将多个对象合并在一起的动态递归函数?
- python - AttributeError:图层没有入站节点 - 发生在 TF >= 2.4 但在 TF < 2.4 中有效?
- xml - 计算 xml 标记中出现频率最高的元素
- python - 为什么 DLL 作为模块导入在 Python2 中有效,而在 Python3 中无效?
- control-m - 是否可以在 Control-M 的可自定义过滤器中使用 AutoEdit 变量?
- wordpress - 子主题不使用子翻译文件