views:

30

answers:

1

I had a bunch of leaks reported by instruments when I ran my app in the simulator using instruments. The leaks reported didn't make much sense to me, so I wanted to try on the device. But when I started from instruments it was either unresponsive (it didn't react to touches, I could only press home to quit) or didn't even start just a black screen was visible on the iphone. Without instruments my app is working fine. Does anybody know what's wrong?

UPDATE1:
I have a UISearchBar in the app attached to a uiSearchDisplayController if i click on it, the program freezes. I can only close it. It is supposed to show an autocomplete table when clicked. If running from simulator it does leak some memory when i click on the search bar, but only for the first time, and it is from an nsurlconnection alloc which is released, both in the didFailWithError and in the connectionDidFinishLoading delegate methods. (I already have a separate unanswered question about this problem.)

UPDATE2: There are some other leaks reported but the only code from my program is the call to UIApplicationMain(argc, argv, nil, nil); which is not very helpful in tracking it down.

A: 

There's no such thing as a leak that only shows up in the simulator. If it leaks in the simulator, it will leak on the device, end of discussion.

You will occasionally see crashes with any of the analysis tools caused by the hooks inserted by the tool interacting with problematic parts of your code. Most likely what you are experiencing is a runaway loop of some kind.

I would suggest resolving on the problems on the simulator before tackling the device.

TechZen
So is it impossible to use instruments on the iphone until i solved all the leaks on the simulator? There are no ocasional crashes, it never works when using instruments and iphone, it only works when using instruments and simulator.
kudor gyozo
What is a runaway loop?
kudor gyozo
Crashing Instruments is unusual but it does happen. You don't normally have to fix in the simulator first. However, it is usually easier to do so. The simulator has more memory and its easy to get the hooks in. If something doesn't work in the simulator it won't work on device so why bother? A runaway loop results from self references causing infinite recursions i.e. an object, object graph, method, function etc that calls itself often tens of thousands of times in a second. Instruments likewise has to produce thousands of hooks to track it and locks up.
TechZen
I don't think i have that kind of loops. I managed to fix some leaks, but it's still not working from instruments if running from iphone.
kudor gyozo
If you have a leak in UIApplication main it is usually caused by an added library, framework etc or a corrupted resources such as an audio file or image. In Instruments, you can examine the stack to trace the leak.
TechZen
If you have an added library that is not compiled for ARM. It may run on the simulator (which is Intel) but crash on the device.
TechZen