To check the memory usage of an iOS app, say if the code is
int n = 1000000;
NSObject *bar = [[NSObject alloc] init];
foo = [[NSMutableArray alloc] initWithCapacity: n];
for (int i = 0; i < n; i++) {
[foo addObject: bar];
}
we can start Instruments and click on Library on toolbar and chose “Memory Monitor”.
But it seems that if I change the code to
n = 10;
and stop Intruments’ Record, and restart Record, the memory use is the same. I have to stop Record, recompile the code in Xcode, and run it, and stop it, and then come back to Instruments and click Record to see the new memory use? Is it always needed to go through that many steps, or is there any simpler way, or even if we can use NSLog to print memory use right inside touchesBegan so whenever we touch the screen, the memory use is printed?
The profile command in Xcode (cmd-I) should do a build and then restart the run in Instruments.