Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FIRApp.configure() creating a memory leak IOS

I've been debugging my application which uses Firebase for memory leaks, and after some time digging into my code I've found that the actual problem is the FIRApp.configure() it inside my application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) in AppDelegate.

As far as I know everything is configured in the right way, I'm using cocoa pods for installing and updating firebase. I'm also modifying my statusBar 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'm also showing the instruments tool to show more details on the leak:

The CFNetwork is the responsible library

And I'm sure it's the FIRApp.configure() because I removed it for testing and there were no leaks.

Hope anyone has an idea on how to fix this leak, thank you.

like image 205
reojased Avatar asked Aug 17 '16 23:08

reojased


1 Answers

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

Here is what I did:

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

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

like image 187
Jun Xiu Chan Avatar answered Nov 01 '22 06:11

Jun Xiu Chan