crash - where to start?

2019-09-13 09:48发布

问题:

I have an app that is crashing on the device (works well in the simulator) which leads me to assume that maybe it's a memory issue...

When it crashes, there is no message whatsoever reported in the console.

It does not crash each time a certain action is taken, it crashes at different points of time always after the app has been running and in use for some time.

I know I'm supposed to ask a more specific question - but if anybody is able to tell me where to start trying to track down a crash that does not report in the console, I would really appreciate it!

I am now using the latest version of XCode (4.2)

Thanks in advance...

回答1:

It very-well could be a memory issue. If that is where you want to start your diagnostics, you can use the built-in Xcode profiler. In Xcode Product->Profile will get you started.



回答2:

Maybe setting the NSZombiesEnabled value to YES in Project -> Edit Active Executable -> Arguments -> Variables is also helping; this will show you memory access errors based on accessing released objects. But in that case you should at least get a SIG_ABRT or BAD_ACCESS error ...

You can also log when the app receives a memory warning in the didReceiveMemoryWarning functions of your view controllers - this is called before the system is throwing out stuff when memory gets low. That of course could lead to a crash with nothing showing.



回答3:

First, relax.

Then read this Technical Note. Now, follow these steps:

  1. From /Users/<username>/Library/Developer/Xcode/DerivedData remove all folders.
  2. From /Users/<username>/Library/Application Support/iPhone Simulator remove all folders.
  3. Clean your trash.
  4. Remove app from device.
  5. Build and run application on device.
  6. Follow the steps that leads toward a crash.

Now, go to XCode->Window->Organizer and select "Device Logs" your device from the DEVICES pane. Select the most recent of these which has your application's name. Wait for XCode to symbolicate the crashlog. There are two possibilities now:

  1. Its a low memory crash.
  2. Its a memory management related crash.

If its option one, profile your application in Instruments.

If its option two, you should see the stack frame where you application is crashing (or your module's stack). This SO question will be very helpful

If you cannot understand the output (or you think the crashlog is not symbolicating - or that its not your code that's crashing), please post the crash log's crashing thread's stack here and I'll look into it.

PS: in the first section we do the first two steps to make sure there are no left-over .app/.dSYM files which might hinder symbolication later in the process because XCode symbolicator is not that intelligent.