我正在使用通过Cocoapods安装的Google Analytics(分析)iOS SDK v3.17.0。当应用打开时,我调试内存图。在图中看到32个内存泄漏。如果不初始化Google Analytics(分析),则在相同情况下也看不到任何泄漏。
我搜索了以下帖子,但没有任何内容包含特定问题和解决方法
https://github.com/firebase/quickstart-ios/issues/239
Memory Leak when Google Analytics sends a hit
我如何初始化:
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
}