Information Technology Reference
In-Depth Information
Getting Started with Instruments
Instruments has some quirks, and the easiest way to become familiar with them is to experiment with a practic-
al profiling project—one that monitors memory events in an iOS app.
Memory management in iOS can be challenging, and Instruments includes tools that can monitor memory and
report on crashes. Although Instruments has many possible applications, memory profiling is one of the most
useful. If you develop for iOS, Instruments can save you time and help you create apps that are robust and
don't leak memory.
Creating a leaky test app
To demonstrate this in practice, you need to create an app that deliberately leaks memory. Instruments monitors
the leak so you can see how allocations and leaks are graphed and summarized as statistics. Follow these steps:
1. Create a new Window-based iOS project in Xcode with File ⇒ New Project.
Don't include unit tests or Core Data.
2. Save the project as MemoryLeak.
3. Modify the start of MemoryLeakAppDelegate.m so it matches the following listing:
@implementation MemoryLeakAppDelegate
@synthesize window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOp-
tions:(NSDictionary *)launchOptions
Search WWH ::




Custom Search