Memory Leaks and ARC
Memory Leaks and ARC
- Subject: Memory Leaks and ARC
- From: Dave <email@hidden>
- Date: Tue, 22 Apr 2014 23:18:24 +0100
Hi,
I’ve been profiling my App for a while now. I have a test class that reads a lof of data from the server, including downloading images. The test runs on a background thread and is started by clicking a button inside a view controller. Although the test read a lot of data, it does’t retain any information beyond the scope of the test method itself. It uses a Network Manager that has some overhead (but not very much) that last as long as the service is connected to it, and it’s never released, so some memory will always be allocated for the life of the app.
Before I run the test, memory is at around 18 MB.
When I run the test the first time, it peaks memory at about 155 MB, then once the test has finished, this drops to 90 MB. When I run it a second time, it peaks at about the same (160 MB), then drops back down to 60ish. If I run it again, it again peaks at about the same, and then drops to 60ish. I think there are some small leaks in there, but nothing major. Since the test runs in a background thread, I can even run 3 or 4 simultaneous tests, it then peaks higher, but drops back to 60MB ish when all tests have completed.
This is the main loop of the mainstay of the allocations, it runs this loop around 650 times loading images of varying sizes:
myCount = [myURLArray count];
LogIfDave(@"myURLArray: %@ Count: %i",myURLArray,myCount);
for (myIndex = 0;myIndex < myCount;myIndex++)
{
myFileURLString = [myURLArray objectAtIndex:myIndex];
myImage = [self commandDownloadImageWithFileURLString:myFileURLString];
if (myImage == nil)
{
LogIfDave(@"Download Failed: %i Count: %i",myIndex,myCount);
continue;
}
LogIfDave(@"Download Image: %i Count: %i",myIndex,myCount);
}
I assumed that ARC would release myImage on each interation of the loop, however, this seems not to be the case, since, I see a massive release when the test conpletes and the Thread terminates.
Is this correct behaviour?
Thanks a lot
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden