Debugging a hang on Mac OS X: Difference between revisions

describe how to use Sampler.app to sample a hung app on OS X, remove irrelevant Shark info (Shark is for profiling, and is too advanced to advise here)
(timeless asked me to put this into wiki)
 
(describe how to use Sampler.app to sample a hung app on OS X, remove irrelevant Shark info (Shark is for profiling, and is too advanced to advise here))
Line 1: Line 1:
If an application hangs, and developers can't reproduce the hang, profiling information from Shark.app or Sampler.app may prove useful to figure out where the hang happens.
If you find a hang in an application, it is very useful for the developer to know where in the code this hang happens, especially if he or she can't reproduce it. Below are steps you can use to attach so-called "Samples" to bug reports.


''Detailed instructions go here.''
=== Creating the sample ===
# When the application is still hung, open up Sampler.app (it's in your <tt>/Developer/Applications/Performance Tools/</tt> folder).
# Choose File > Attach...
# Select "firefox-bin" or the hung application you want a sample from.
# Now, click "Start recording". Note that only 3-4 seconds usually suffice, note that '''this will quickly hog up a lot of memory''' if you leave it on for too long!
# When it's done parsing the data, you should now have a couple of rows with stacktraces for all the threads in the sampled application.


== References ==
=== Exporting it to a usable form ===
* [http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/shark.1.html shark manual]
When you have the raw Sample data, you can't just save that and attach it to a bug, because the format is not very usable (unless the developer is a mac hacker). Export it like this:
* [http://developer.apple.com/tools/shark_optimize.html Optimize with Shark]
 
# ''(Optional)'' Choose Tools > Invert Call Graph
# Choose Tools > Generate Report, and attach this as a text file to the bug report.
 
The final data will show where the application spent all its time when it was hung, and hopefully your bug will be easier to fix now!
107

edits