Tuesday, 10 September 2013

Downloading images using AFNetworking - Memory won't release after poping ViewController using ARC

Downloading images using AFNetworking - Memory won't release after poping
ViewController using ARC

I've experienced some weird memory issues with my app. After some
debugging I've isolated the problem to a new project with one View
controller. So right now my testing app contains a UINavigationController
connected to a ViewController with a button that pushes the next
ViewController:
#import "ViewController.h"
#import "AFNetworking.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
for(int i=0;i<100;i++)
{
NSString *rightImageUrl = [NSString
stringWithFormat:@"%@/%@-iphone%@.png",ImagesURL,[NSString
stringWithFormat:@"%d",i],@"4"];
UIImageView *rightImageView = [[UIImageView
alloc]initWithFrame:CGRectMake(6, 50*i , 139, 200)];
[rightImageView setImageWithURL:[NSURL URLWithString:rightImageUrl]];
[self.view addSubview:rightImageView];
}
}
The above is all the code I have in my testing app right now.
According to Instruments the above takes X amount of memory (10mb, 20mb ..
Depending on the amount of loops) The problem is that the memory allocated
from the above won't be released when I'll pop the ViewController.
I've tried wrapping the code inside the for loop with @autoreleasepool but
that didn't do much.
Am I doing something wrong?

No comments:

Post a Comment