aherlambang
aherlambang

Reputation: 14418

NSURLConnection sucking memory when profiled using leaks

I am having a really hard time optimizing my app performance as it sucks too much memory. Here's the allocation instruments call tree:

enter image description here

I am unsure my self why it's sucking 5 MB of the app it self.. the leaks instruments is not showing that I am leaking up any memory. Any idea why this might be happening?

Upvotes: 0

Views: 297

Answers (1)

Adam
Adam

Reputation: 41

Perhaps try setting the shared NSURLCache to something that is reasonable for your application.

See http://twobitlabs.com/2012/01/ios-ipad-iphone-nsurlcache-uiwebview-memory-utilization/ for an example:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{   
    int cacheSizeMemory = 4*1024*1024; // 4MB
    int cacheSizeDisk = 32*1024*1024; // 32MB
    NSURLCache *sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease];
    [NSURLCache setSharedURLCache:sharedCache];

    // ... more launching code
}

Upvotes: 1

Related Questions