rano
rano

Reputation: 5676

Xcode debug with iPhone app is slow and laggy

I am debugging an iPhone app I'm writing in Xcode, but sometimes now the debugger (which is GDB) slows a lot (doing a step-by-step debugging) and becomes unresponsive sometimes (the icons for stepping-in, stepping-over, stepping-out are not clickable), after sometimes it gets back to normal and continues and other times it stay like that forever or a message appears in console: "Timed out" (or something similar) and I can see my CPU from activity monitor going up to 90%. As a workaround I used to put a brekpoint after the line of code I was interested in and simply went with 'Continue' to 'Continue' (doing so it run perfectly fine and fast). Can this be code dependent? Is there a way I can debug the debugger (behaviour) ?

UPDATE: The complete message is

Timed out fetching data. Variable display may be inaccurate.

Googling for it i discovered that it happens when Xcode gdb is trying to look inside data formatters. Someone suggested to disable Run>Variable View>Use Data Formatter (in xcode 3.2, previous i guess it is Debug->Variables View->Enable Data Formatters) and it seems to work for me too (till now) So now I am asking: why? : D

UPDATE2: This solved the debugger from stopping on a specific part of the code but it stil hangs (with the same message) in another calling. It seems to me that this involves some CoreData API like (NSEntityDescription*)entityForName: inManagedObjectContext:

UPDATE3: Would it be best to cache the NSEntityDescription instead of creating always a new one?

Upvotes: 18

Views: 10401

Answers (6)

deepwinter
deepwinter

Reputation: 4678

I have observed very slow debugging when 'Queue Debugging' is enabled in the scheme. If you don't need queue debugging, consider disabling it.

Upvotes: 11

Krešimir Prcela
Krešimir Prcela

Reputation: 4281

I had the same issue and found some related answer on apple's discussion:

One common cause of problems is trying to run the data formatters on uninitialized objects. We don't actually have any way to tell for sure when an object is good or not. We have some heuristics, but stack objects sometimes point to the leftovers of another stack object that are "almost good enough" and fool us. One trick that will help out with this is when you are breaking in a function, break after the objects are initialized, not at the very beginning of the function.

Upvotes: 2

cregox
cregox

Reputation: 18406

I'm very new to Xcode debugging, but while doing my research I stumbled upon this question which may be helpful to your issue.

Basically there are two people in there who had many issues with xcode debugging and the OP solved his issue through a clean install. Quoting LucasTizma's 4th edit:

FINALLY got device debugging to work. I have a feeling that something low-level on my device was causing issues...nothing I did worked on my system. However, I installed Xcode on another system and device debugging on the same device (with the same cable) worked flawlessly. Directly after that, device debugging began working on my original machine, leading me to believe that some strange hardware flag was screwed up and somehow "reset" on the second machine. In any case, it works now.

Upvotes: -1

Aditya
Aditya

Reputation: 4396

I have also faced same problem as soon as i migrated to xCode 3.2. i have been using xcode 3.0 and 2.0 , i never faced this problem in those SDKs. So i think this is an issue with the new SDK.

Upvotes: 0

ERiDeM
ERiDeM

Reputation: 41

I had a same problem and I solved it disabling the option "Run" - "Enable/Disable Guard Alloc" in xCode. Now it works so fast! Check if you have this option enabled and disable it.

Hope it helps! :D

Upvotes: 1

Neal L
Neal L

Reputation: 4339

Try running your code in Instruments. This could be a memory issue, so watch your utilization in Instruments as the code runs. When you get to the part where it becomes less and less responsive, you should see the memory usage go up and be able to trace back from there in Instruments.

Hope this helps!

Upvotes: 0

Related Questions