Debugging methods to find the location and errors causing the game to freeze

I recently stumbled upon an error that I cannot understand. The game I'm developing using Cocos2D just crashes at a certain random point - it gets SIGSTOP - and I can't find the reason. What tool can I use (and how to use it) to find out where the error occurs and what causes it?

+7
source share
2 answers

Jeremy's suggestion for a stop in the debugger is a good one.

There's a really quick way to investigate freezing (or any performance issue), especially when it's not easy to reproduce. You should have a convenient terminal (so you will need to work in the iOS simulator or in Mac OS X, and not on the iOS device).

When the freeze occurs, go to the terminal and run:

  sample YourProgramName

(If your program name has quotation marks, such as sample "My Awesome Game" .) The output from sample is a log showing where your program is wasting time, and if your program is actually hanging, it will be pretty obvious which functions get stuck .

+8
source

I disagree with the Aaron Golden answer above, since working on the device is extremely useful to have a real scenario of where the application freezes. The simulator has more memory and does not reproduce the device hardware accurately (for example, the frame rate is lower in some cases).

โ€œObviouslyโ€, you need to connect your device (with a developer profile) to Xcode and look at the console terminal to find the tracks suggested by @AaronGolden user.

If this is not enough, you can include a common exception checkpoint in Xcode to capture more stacktrace messages.

When I started learning Cocos2D, my application often lingers. This is a list of common reasons:

  • I did not use sprite sheets, and therefore the frame rate dropped sharply
  • I used too much memory (too many high-definition sprites. Look at TexturePacker and use pvr.ccz or pvr.gz, reduces memory allocation by half)

Use instruments to profile your application for memory alerts (for example, look at selection tools and find memory alerts).

+1
source

All Articles