I am running into some issues with the memory management on my app. The app will run properly for a while, then I will get a Received memory warning error. I then ran my app through Profile to find the memory leaks. After tracking the leaks, I got a 100% memory leak on this line:
[self performSelectorOnMainThread:@selector(loadingProgress:) withObject:[NSNumber numberWithFloat:0.0] waitUntilDone:NO];
I may be naive, but I didn’t know that this could leak…
Anyone know how I can fix this?
The only possible leak is if you are over-retaining the
NSNumberinstance in your thread. But for that to cause a crash, you’d have to be spinning off thousands and thousands of threads, indicating a very serious problem in and of itself.Note that the Leaks instrument shows you where the leak was allocated, not where it might have been over-retained.
Likewise, leaks only shows, well, leaks. It won’t show accretion of allocations where the allocations are still referenced by the global object graph. I.e. if an object is reachable by a reference path starting at a global variable, then it isn’t a leak.
Try heapshot analysis. It is very good at finding this kind of accretion over time.