Analysis Tools
Analysis tools let you actively gather data about the performance of your program. You can view these tools in a way similar to debugging tools. You use them to investigate problems and gather information needed to go back and revise your code. Unlike debugging tools, most analysis tools provide a way to save data from a session so that you can view it later, which is very useful for charting the progress of your application.
With the exception of Shark, most of the analysis tools are geared towards finding specific types of performance problems. While any one tool might give you useful information, it is important to run several tools on the same code to view problems from several different angles. For example, using ObjectAlloc, you might find that your program creates a number of objects, but running MallocDebug you might find that many of those objects are actually being leaked. Shark provides many ways to gather and view information and is indispensable for finding performance problems in your code.
Table 3-1 lists the analysis tools installed with the Xcode Tools. Applications such as Shark are installed in the /Developer/Applications/Performance Tools directory. Command-line tools, such as heap and leaks, are installed in /usr/bin.
Table 3-1 Analysis toolsTool | Description |
MallocDebug | Tracks and analyzes memory allocated in an application. You can use this tool to find memory leaks or analyze memory allocation patterns. |
ObjectAlloc | Tracks Objective-C and Core Foundation object allocations and deallocations in real time. The tool also lets you view the retention history for an object, which can be useful in recovering memory held by over-retained objects. |
OpenGL Driver Monitor | Gathers GPU-related performance data, including data related to VRAM usage, video bus traffic, and hardware stalls among others. You can use this information to identify the cause of temporary slowdowns or sporadic hesitations in your OpenGL application. |
OpenGL Profiler | Creates a runtime profile of your OpenGL-based application. You can view function statistics and the call-trace history of your application’s OpenGL calls. |
Sampler | Analyzes your application’s behavior at runtime. It can identify where your program spends its time and summarize how often allocation routines, system calls, or arbitrary functions were called. |
Saturn | Instruments your code to provide function-level profiling and displays the resulting data graphically. You can use this tool to count events, such as how many times a function is called or an event is sent. |
Shark | Does statistical sampling of all processes and threads in the system. You can also use Shark to trace function calls, including malloc calls, and to chart information graphically. Shark helps you to isolate problems quickly by providing a rich set of data-mining features and is an indispensable tool for finding performance bottlenecks. |
heap
| Lists all malloc-allocated buffers in the heap of a specified process |
leaks
| Searches the memory space of a process for any allocated but unreferenced blocks of memory. |
vmmap
| Displays the virtual memory regions allocated to a specified process. You can use this tool to analyze the memory usage of your process. |