Search code examples
iosxcodeios-4.2xcode3.2ios4

Can't figure out memory leak testing with simulator and in general


EDIT: guys, my question was about using the Instruments to see leaks, and the code as an example and side question, but you answered the side question and not the main problem.... Thank you for the answers, but I really need to find out how to work the Instruments with the simulator....

I am learning IOS development, In one of the codes I'm studying i think there is huge memory leak so I've tried learning how to use instruments. As i am learning right now, I am trying to use instruments with the simulator, but all the manuals i found are for connecting to a device and then using instruments and not with the simulator. every thing I've tried doesn't show any leaks in Instruments.

The app doesn't crash because i am guessing the memory leak is not that big, but when i am adding the following code it does crash, why is that, Even when i added the release every time, still crashes....what is wrong with the simulator? or with the code? working with xcode3, not 4.

for (int i = 0; i < 1000000; i++) {
    NSString *testLeak = [[NSString alloc] initWithString:@"test1223"];
    NSLog(@"%@",testLeak);
    [testLeak release];
}

And again, the app crashes and the simulator doesn't show any leaks, even when i put the "attach process" on "iPhone simulator".


Solution

  • Thank you all, I actualy Found the answer around 4 am yestorday... when you want to test leaks on the emulator:

    rum -> run with Performance Tool ->Leaks

    If you select the simulator on the top right as the device to run the app on, It will lounch the simulator and the instruments and start the leak recorder, all in one click....

    Have fun :-) Erez