FIRApp.configure () creates iOS memory leak

I was debugging my application that uses Firebase to leak memory, and after a while digging into my code, I found that the actual problem is FIRApp.configure() inside my application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) in AppDelegate.

As far as I know, everything is configured correctly, I use cocoa pods to install and update firebase. I also change my Bar status inside my AppDelegate, the code is as follows:

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { FIRApp.configure() setStatusBarBackgroundColor(UIColor(red: 231/250, green: 97/250, blue: 44/250, alpha: 1.0)) // Override point for customization after application launch. return true } var window: UIWindow? override init() { } func setStatusBarBackgroundColor(color: UIColor) { guard let statusBar = UIApplication.sharedApplication().valueForKey("statusBarWindow")?.valueForKey("statusBar") as? UIView else { return } statusBar.backgroundColor = color } 

I also show a tooling tool to show more details about the leak:

CFNetwork is a responsible library

And I'm sure this is FIRApp.configure() , because I deleted it for testing and there were no leaks.

Hope anyone has an idea how to fix this leak, thanks.

+6
source share
1 answer

I have the same problem. After some digging, it seems that Firebase Analytics is causing the leak.

Here is what I did:

  • set FIREBASE_ANALYTICS_COLLECTION_ENABLED to NO
  • FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED until YES in GoogleServiceIn-info.plist .

At least it works for me. For those who rely on firebase analytics, this is definitely a mistake.

+1
source

All Articles