Search code examples
iosmemory-leaksxcode4.2automatic-ref-countingflurry

Flurry Analytics - NSAutoreleasePool allocWithZone:] - memory leak after upgrading to Objective-C ARC


I just recently upgraded my project to iOS 5 with ARC (automatic reference counting) and now Instruments is reporting a memory leak from NSAutoreleasePool after I suspend the app in the background.

I suspect the leak is being caused by Flurry Analytics based on the stack trace with these two API calls:

+[FlurrySession sendSessionsToServerForSessionPause]
+[FlurrySession sendSessionsToServerWithTimeout:useWebView:requestAppCircleAds:requestVideoAds:requestAppSpotAds:sendCurrentSession:]

I'm not making any Flurry API calls on suspend. The only call being made to flurry is

[FlurryAnalytics startSession:<my id>];

when the app first starts.

Reported leak

Leaked Object   #       Address     Size        Responsible     Library Responsible Frame

NSAutoreleasePool,1     0x7693f600  32 Bytes    Foundation      +[NSAutoreleasePool allocWithZone:]

Stack trace

  10 libsystem_c.dylib thread_start
   9 libsystem_c.dylib _pthread_start
   8 Foundation __NSThread__main__
   7 Foundation -[NSThread main]
   6 iSURVEY +[FlurrySession sendSessionsToServerForSessionPause] /Developer/Applications/iPhoneAdAgent_modular/Classes/FlurrySession.m:931
   5 iSURVEY +[FlurrySession sendSessionsToServerWithTimeout:useWebView:requestAppCircleAds:requestVideoAds:requestAppSpotAds:sendCurrentSession:] /Developer/Applications/iPhoneAdAgent_modular/Classes/FlurrySession.m:962
   4 CoreFoundation +[NSObject(NSObject) alloc]
   3 Foundation +[NSAutoreleasePool allocWithZone:]
   2 CoreFoundation +[NSObject(NSObject) allocWithZone:]
   1 libobjc.A.dylib class_createInstance
   0 libsystem_c.dylib calloc

Edit:

I just tried turning off all debug variables like zombies and the memory leak is still exactly the same.

Edit 2:

Okay I've confirmed that it definitely is a Flurry issue. After removing the call

[FlurryAnalytics startSession:<my id>];

I no longer get the memory leak.

I'll file a bug with the Flurry team.


Solution

  • I see the same 32 byte leak. I was thinking about releasing it that way, and watching for an update. A one time 32 byte leak doesn't seem like it's a big problem. I only see it when the App registers with Flurry, not every time the task comes out of the background. I'm using Flurry version 3.0.2 with iOS 5.0 as the base SDK, and a target of iOS 4.1

    Looking at the Flurry docs, it looks like you can set it up to only report on application launch.

    Before your

    [FlurryAnalytics startSession:id];
    

    Add the following two calls:

    [FlurryAnalytics setSessionReportsOnCloseEnabled:NO];
    [FlurryAnalytics setSessionReportsOnPauseEnabled:NO];
    

    The docs say that "OnPause" is off by default, but it can't hurt to be sure.

    I also filed a bug report with Flurry.