This is on iOS, device is iPad.
Here's what happens:
- I run app on device or debug and run using Xcode.
- After 5 minutes I receive a memory warning of level 1.
- A minute later I receive a memory warning of level 2.
- Another minute later,
Program received signal: “0”.
I checked for leaks using Leaks in Instruments and detected no leaks.
However, according to Activity Monitor, my app initially uses 30 MB, and grows in size to over 100mb over time (about 200kb per second!). So, apparently Leaks doesn't detect all memory leaks.
So my question: if Leaks can't detect it, are there any general tips to finding them, and is there a better tool to find these leaks?
This is how I would approach it,
Name all you classes with a prefix so you can easily see them in Instruments
XCode->Run->Run with performance tool->allocations
Now stop your app and type the name of class you suspect is leaking in the search box. (this is where the prefix is handy). The start instruments again with the "Record" button
- The living column should go up and down as you allocate objects. Note if it doesn't go down you have a leak.
It is always not necessary that you have leaks in the case you have mentioned. You might have used lot of autoreleased objects in the point of execution time that you mention here.
You might be adding a heavily sized objects to a collection object. If that is the case, use a separate Autorelease pool for that case, reduce the memory footprint of the application.
It's preferred if you can make use tools to find leaks, but if are completely stumped, there is another technique that I use.
Start with commenting out almost everything and then slowly add back one component at a time until the memory leak occurs again. That way you can zero in on the function or block of code that is creating the problem.