Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.3: Use Activity Monitor to 'sample' running applications System
I discovered a new feature of Activity Monitor today that could be one of the best debugging tools in the Mac OS to date: application sampling. While viewing the process list in Activity Monitor's main window, select an application and choose "Sample" from the Process menu. This is also available as a button in the Inspector window. Wait a few seconds while the sample is taken, and you will see exactly what functions the application is executing at that moment.

Why is this useful if you're not a programmer? Well, consider a problem I was having with Photoshop this evening: whenever I would open or create a file, Photoshop would hang with a stopwatch cursor. Initially unable to diagnose the problem, I opened Activity Viewer, took a sample, and discovered that the main thread was looping deep in a series of calls that had names including "CUPS" and "Printer." I checked the status of my CUPS print server, and sure enough, it wasn't online (which, incidentally, meant that I had Panther's shoddy networking to blame for the hang). I opened Printer Setup Utility and deleted the networked printer, and Photoshop instantly returned to life.
    •    
  • Currently 2.80 / 5
  You rated: 3 / 5 (10 votes cast)
 
[19,288 views]  

10.3: Use Activity Monitor to 'sample' running applications | 2 comments | Create New Account
Click here to return to the '10.3: Use Activity Monitor to 'sample' running applications' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: Use Activity Monitor to 'sample' running applications
Authored by: acdha on Dec 01, '03 03:15:00PM
Alternately: killall -u username

[ Reply to This | # ]
10.3: Use Activity Monitor to 'sample' running applications
Authored by: jiga on Dec 01, '03 04:33:31PM
How do I interpret the results? (I'm quite a newbie...) Safari hangs for 2-8 seconds frequently on various sites, so I guess that sampling would help in this case.

I turned sampling on during such a hang on macosxhints.com, and this is what resulted - could anybody take a short look at it?

Thanks :-)

2003-12-01 22:32:05.923 sample[640] Couldn't start c++filt for C++ name demangling
Analysis of sampling pid 535 every 10.000000 milliseconds
Call graph:
    195 Thread_0e0b
      195 0xc714
        195 0xc8a0
          195 0x92eb9a1c
            195 0x92dfd730
              195 0xedd4
                195 0x92de93fc
                  195 0x92dd2a80
                    195 0x927fe6d0
                      195 0x927dc640
                        195 0x927d5ecc
                          195 CFRunLoopRunSpecific
                            195 __CFRunLoopRun
                              195 __CFRunLoopDoTimer
                                195 __NSFireDelayedPerform
                                  156 0x6ff48
                                    156 +[NSPropertyListSerialization dataFromPropertyList:format:errorDescription:]
                                      155 __CFBinaryPlistWriteToStream
                                        150 _flattenPlist
                                          150 _flattenPlist
                                            150 _flattenPlist
                                              150 _flattenPlist
                                                121 _flattenPlist
                                                  120 CFSetAddValue
                                                    115 __CFSetGrow
                                                      111 __CFSetFindBuckets2
                                                        78 __plistUniquingEqual
                                                          52 CFEqual
                                                            35 __CFArrayEqual
                                                              23 CFEqual
                                                                12 CFEqual
                                                                11 __CFStringEqual
                                                                  11 __CFStringEqual
                                                              10 __CFArrayEqual
                                                              2 __CFStringEqual
                                                                2 __CFStringEqual
                                                            11 CFEqual
                                                            5 CFEqual
                                                              5 CFEqual
                                                            1 __CFStringEqual
                                                              1 __CFStringEqual
                                                          16 CFGetTypeID
                                                            16 CFGetTypeID
                                                          5 __plistUniquingEqual
                                                          4 __CFArrayEqual
                                                            4 __CFArrayEqual
                                                          1 CFNumberGetTypeID
                                                            1 CFNumberGetTypeID
                                                        18 __CFSetFindBuckets2
                                                        9 CFGetTypeID
                                                          9 CFGetTypeID
                                                        5 CFEqual
                                                          5 CFEqual
                                                        1 __CFStringHash
                                                          1 __CFStringHash
                                                      3 __plistUniquingEqual
                                                        3 __plistUniquingEqual
                                                      1 __CFSetGrow
                                                    5 __CFSetFindBuckets2
                                                      4 __CFSetFindBuckets2
                                                      1 __plistUniquingEqual
                                                        1 CFGetTypeID
                                                          1 CFGetTypeID
                                                  1 CFSetGetValue
                                                    1 __CFSetFindBuckets1
                                                      1 __plistUniquingEqual
                                                        1 CFGetTypeID
                                                          1 CFGetTypeID
                                                25 CFSetAddValue
                                                  24 __CFSetFindBuckets2
                                                    15 __plistUniquingEqual
                                                      9 CFEqual
                                                        4 CFEqual
                                                        4 __CFArrayEqual
                                                          2 __CF_INVOKE_CALLBACK
                                                            2 __CF_INVOKE_CALLBACK
                                                          1 CFEqual
                                                            1 CFEqual
                                                          1 __CFArrayEqual
                                                        1 CFEqual
                                                          1 CFEqual
                                                      4 CFGetTypeID
                                                        4 CFGetTypeID
                                                      1 __CFArrayEqual
                                                        1 __CFArrayEqual
                                                      1 __plistUniquingEqual
                                                    4 __CFSetFindBuckets2
                                                    3 CFEqual
                                                      3 CFEqual
                                                    2 CFGetTypeID
                                                      2 CFGetTypeID
                                                  1 __plistUniquingEqual
                                                    1 __plistUniquingEqual
                                                3 CFSetGetValue
                                                  3 __CFSetFindBuckets1
                                                    2 CFGetTypeID
                                                      2 CFGetTypeID
                                                    1 __CFSetFindBuckets1
                                                1 __memcpy
                                                  1 __memcpy
                                        2 __CFBinaryPlistWriteToStream
                                        1 CFDictionaryGetValue
                                          1 CFDictionaryGetValue
                                        1 CFRelease
                                          1 __CFSetDeallocate
                                            1 CFSetRemoveAllValues
                                              1 CFRelease
                                                1 CFRelease
                                        1 CFStringGetBytes
                                          1 CFStringGetBytes
                                      1 0x9022a64c
                                        1 0x9022a64c
                                  33 0x246e8
                                    33 0x9531e2ec
                                      33 0x9531e37c
                                        25 0x9531e43c
                                          25 -[NSDictionary writeToURL:atomically:]
                                            20 CFPropertyListCreateXMLData
                                              13 _CFGenerateXMLPropertyListToData
                                                13 _CFAppendXML0
                                                  13 _CFAppendXML0
                                                    12 _CFAppendXML0
                                                      4 CFArraySortValues
                                                        3 __CF_FAULT_CALLBACK
                                                          3 _dyld_image_containing_address
                                                            3 _dyld_image_containing_address
                                                              3 _dyld_get_image_header_containing_address
                                                                3 _dyld_get_image_header_containing_address
                                                        1 CFQSortArray
                                                          1 CFStringCompareWithOptions
                                                            1 CFStringCompareWithOptions
                                                      4 _CFAppendXML0
                                                        2 _plistAppendFormat
                                                          1 CFRelease
                                                            1 szone_free
                                                              1 szone_free
                                                          1 _CFStringCreateWithFormatAndArgumentsAux
                                                            1 CFRelease
                                                              1 szone_free
                                                                1 szone_free
                                                        1 CFDataAppendBytes
                                                          1 CFDataAppendBytes
                                                        1 _appendEscapedString
                                                          1 _appendEscapedString
                                                      2 _plistAppendCharacters
                                                        1 CFDataAppendBytes
                                                          1 CFDataAppendBytes
                                                        1 _plistAppendCharacters
                                                      1 CFDictionaryGetValue
                                                        1 __CFDictionaryFindBuckets1b
                                                          1 __CFDictionaryFindBuckets1b
                                                      1 _appendEscapedString
                                                        1 _plistAppendCharacters
                                                          1 _plistAppendCharacters
                                                    1 _CFArrayReplaceValues
                                                      1 _CFArrayReplaceValues
                                              7 CFPropertyListIsValid
                                                7 __CFPropertyListIsValidAux
                                                  7 CFDictionaryApplyFunction
                                                    7 __CFPropertyListIsDictPlistAux
                                                      7 __CFPropertyListIsValidAux
                                                        7 CFArrayApplyFunction
                                                          7 __CFPropertyListIsArrayPlistAux
                                                            7 __CFPropertyListIsValidAux
                                                              7 CFDictionaryApplyFunction
                                                                7 __CF_FAULT_CALLBACK
                                                                  7 _dyld_image_containing_address
                                                                    7 _dyld_image_containing_address
                                                                      7 _dyld_get_image_header_containing_address
                                                                        7 _dyld_get_image_header_containing_address
                                            5 _NSIsPList
                                              5 _NSIsPList
                                                5 _NSIsPList
                                                  2 -[NSCFDictionary keyEnumerator]
                                                    1 CFDictionaryGetKeysAndValues
                                                      1 CFDictionaryGetKeysAndValues
                                                    1 NSAllocateObject
                                                      1 _internal_class_createInstanceFromZone
                                                        1 malloc_zone_calloc
                                                          1 0x900fac48
                                                            1 0x900fac48
                                                  2 _NSIsPList
                                                    2 _NSIsPList
                                                  1 NSAllocateObject
                                                    1 NSAllocateObject
                                        8 0x9531e3dc
                                          7 0x9530dfb0
                                            4 0x953085b0
                                              4 +[NSString stringWithFormat:]
                                                4 _CFStringCreateWithFormatAndArgumentsAux
                                                  2 CFRelease
                                                    2 szone_free
                                                      2 szone_free
                                                  2 _CFStringAppendFormatAndArgumentsAux
                                                    1 _CFStringAppendFormatAndArgumentsAux
                                                    1 snprintf
                                                      1 __vfprintf
                                                        1 __dtoa
                                                          1 __dtoa
                                            2 0x9530860c
                                              2 -[NSCFDictionary setObject:forKey:]
                                                1 CFDictionarySetValue
                                                  1 CFRetain
                                                    1 CFRetain
                                                1 __CFDictionaryFindBuckets2
                                                  1 __CFDictionaryFindBuckets2
                                            1 0x9530851c
                                              1 -[NSCFDictionary setObject:forKey:]
                                                1 CFDictionarySetValue
                                                  1 CFDictionarySetValue
                                          1 0x9530dfc4
                                            1 CFArrayAppendValue
                                              1 _CFArrayReplaceValues
                                                1 _CFArrayReplaceValues
                                  4 0x6ff64
                                    4 0x6edd8
                                      4 0x73d64
                                        4 0x9210e9a8
                                          4 0x9210ee00
                                            4 0x9210ef84
                                              4 0x920f4c60
                                                2 0x920f718c
                                                  1 0x9210f900
                                                    1 0x9210f900
                                                  1 0x92110170
                                                    1 0x92110170
                                                1 0x920f7150
                                                  1 0x920f7150
                                                1 0x920f719c
                                                  1 __memcpy
                                                    1 __memcpy
                                  1 0x6ff94
                                    1 -[NSData writeToFile:atomically:]
                                      1 _NSWriteBytesToFile
                                        1 fsync
                                          1 fsync
                                  1 0x6ffac
                                    1 chmod
                                      1 chmod
    195 Thread_0f03
      195 _pthread_body
        195 __ape_agent
          195 __ape_internal
            195 mach_msg
              195 mach_msg_trap
                195 mach_msg_trap
    195 Thread_1003
      195 _pthread_body
        195 forkThreadForFunction
          195 0x953185b8
            195 -[NSRunLoop run]
              195 -[NSRunLoop runMode:beforeDate:]
                195 CFRunLoopRunSpecific
                  195 __CFRunLoopRun
                    195 mach_msg
                      195 mach_msg_trap
                        195 mach_msg_trap
    195 Thread_1103
      195 _pthread_body
        195 forkThreadForFunction
          195 +[NSURLConnection(NSURLConnectionInternal) _resourceLoadLoop:]
            195 -[NSRunLoop run]
              195 -[NSRunLoop runMode:beforeDate:]
                195 CFRunLoopRunSpecific
                  195 __CFRunLoopRun
                    195 mach_msg
                      195 mach_msg_trap
                        195 mach_msg_trap
    195 Thread_1203
      195 _pthread_body
        195 _loadRunLoop
          195 select
            195 select
    195 Thread_1303
      195 _pthread_body
        195 forkThreadForFunction
          195 +[NSURLCache _diskCacheSyncLoop:]
            195 -[NSRunLoop run]
              195 -[NSRunLoop runMode:beforeDate:]
                195 CFRunLoopRunSpecific
                  195 __CFRunLoopRun
                    195 mach_msg
                      195 mach_msg_trap
                        195 mach_msg_trap
    195 Thread_1403
      195 _pthread_body
        195 forkThreadForFunction
          195 0x92dca928
            195 -[NSConditionLock lockWhenCondition:]
              195 _pthread_cond_wait
                195 semaphore_wait_signal_trap
                  195 semaphore_wait_signal_trap
    195 Thread_1503
      195 _pthread_body
        195 0x9496f9cc
          195 0x9487f7a0
            195 0x9487f80c
              195 mach_msg
                195 mach_msg_trap
                  195 mach_msg_trap
    195 Thread_1603
      195 _pthread_body
        195 0x9496f9cc
          195 0x94897b8c
            195 0x947f0480
              195 0x947da944
                195 0x947a7688
                  195 mach_msg
                    195 mach_msg_trap
                      195 mach_msg_trap
    195 Thread_1703
      195 _pthread_body
        195 0x9496f9cc
          195 0x948145d4
            195 0x948cdeac
              195 0x94829120
                195 0x94818868
                  195 0x947dbce8
                    195 0x947ba0f8
                      195 0x8c1616c
                        195 0x8c18fb0
                          195 0x8c18fb0
                            195 0x8c1f580
                              195 0x947a7ae8
                                195 0x947ab3a4
                                  195 0x947a2034
                                    195 0x947a7608
                                      195 mach_msg
                                        195 mach_msg_trap
                                          195 mach_msg_trap
    195 Thread_1803
      195 _pthread_body
        195 0x9496f9cc
          195 0x948145d4
            195 0x948cdeac
              195 0x94829120
                195 0x94818868
                  195 0x947dbce8
                    195 0x947ba0f8
                      195 0x8c1616c
                        195 0x8c18ec0
                          195 0x8d5eda8
                            195 0x8d5f048
                              195 0x8d33ba4
                                195 0x947a7ae8
                                  195 0x947ab3a4
                                    195 0x947a2034
                                      195 0x947a7608
                                        195 mach_msg
                                          195 mach_msg_trap
                                            195 mach_msg_trap
    195 Thread_1903
      195 _pthread_body
        195 0x9496f9cc
          195 0x947b72d0
            195 0x947b7130
              195 0x947a7688
                195 mach_msg
                  195 mach_msg_trap
                    195 mach_msg_trap
    195 Thread_1a03
      195 _pthread_body
        195 0x9496f9cc
          195 0x948145d4
            195 0x948d2044
              195 0x948d2e80
                195 semaphore_wait_trap
                  195 semaphore_wait_trap
    195 Thread_1b03
      195 _pthread_body
        195 0x9496f9cc
          195 0x948145d4
            195 0x947fda2c
              195 0x94811ce0
                195 0x947da9a4
                  195 0x947a7608
                    195 mach_msg
                      195 mach_msg_trap
                        195 mach_msg_trap
    195 Thread_1c03
      195 _pthread_body
        195 0x9496f9cc
          195 0x948145d4
            195 0x948cdeac
              195 0x94829120
                195 0x94818868
                  195 0x947dbce8
                    195 0x947ba0f8
                      195 0x8c1616c
                        195 0x8c19310
                          195 0x8c18fb0
                            195 0x8c18fb0
                              195 0x8c1f580
                                195 0x947a7ae8
                                  195 0x947ab3a4
                                    195 0x947a2034
                                      195 0x947a7608
                                        195 mach_msg
                                          195 mach_msg_trap
                                            195 mach_msg_trap
    195 Thread_1d03
      195 _pthread_body
        195 0x9496f9cc
          195 0x948145d4
            195 0x948cdeac
              195 0x94829120
                195 0x94818868
                  195 0x947dbce8
                    195 0x947ba0f8
                      195 0x8c1616c
                        195 0x8c18fb0
                          195 0x8c1f580
                            195 0x947a7ae8
                              195 0x947ab3a4
                                195 0x947a2034
                                  195 0x947a7688
                                    195 mach_msg
                                      195 mach_msg_trap
                                        195 mach_msg_trap
    195 Thread_1e03
      195 _pthread_body
        195 0x9496f9cc
          195 0x948145d4
            195 0x948cdeac
              195 0x94829120
                195 0x94818868
                  195 0x947dbce8
                    195 0x947ba0f8
                      195 0x8c1616c
                        195 0x8c18fb0
                          195 0x8c18fb0
                            195 0x8c18fb0
                              195 0x8c18e30
                                195 0x8d6f134
                                  195 0x8d41f98
                                    195 0x8d33ba4
                                      195 0x947a7ae8
                                        195 0x947ab3a4
                                          195 0x947a2034
                                            195 0x947a7608
                                              195 mach_msg
                                                195 mach_msg_trap
                                                  195 mach_msg_trap
    195 Thread_1f03
      195 _pthread_body
        195 0x9496f9cc
          195 0x948145d4
            195 0x948cdeac
              195 0x94829120
                195 0x94818868
                  195 0x947dbce8
                    195 0x947ba0f8
                      195 0x8c1616c
                        195 0x8c19310
                          195 0x8c18ec0
                            195 0x8d5eda8
                              195 0x8d5f048
                                195 0x8d33ba4
                                  195 0x947a7ae8
                                    195 0x947ab3a4
                                      195 0x947a2034
                                        195 0x947a7608
                                          195 mach_msg
                                            195 mach_msg_trap
                                              195 mach_msg_trap
    195 Thread_2003
      195 _pthread_body
        195 __CFSocketManager
          195 select
            195 select

Total number in stack (recursive counted multiple, when >=5):
        18       _pthread_body
        14       mach_msg
        14       mach_msg_trap
        11       0x9496f9cc
        8       0x8c18fb0
        8       0x948145d4
        8       CFEqual
        7       CFGetTypeID
        6       0x8c1616c
        6       0x947a2034
        6       0x947a7608
        6       0x947a7ae8
        6       0x947ab3a4
        6       0x947ba0f8
        6       0x947dbce8
        6       0x94818868
        6       0x94829120
        6       0x948cdeac
        6       __plistUniquingEqual
        5       CFRelease
        5       _flattenPlist

Sort by top of stack, same collapsed (when >= 5):
        mach_msg_trap        2730
        select        390
        semaphore_wait_signal_trap        195
        semaphore_wait_trap        195
        CFEqual        42
        CFGetTypeID        35
        __CFSetFindBuckets2        26
        __CFArrayEqual        16
        __CFStringEqual        14
        __plistUniquingEqual        10
        _dyld_get_image_header_containing_address        10
Sample analysis of process 535 written to file /dev/stdout
Sampling process 535 each 10 msecs 300 times


[ Reply to This | # ]