Yevgeniy Solodovnikov xcode instruments_usage
-
Upload
dneprciklumevents -
Category
Technology
-
view
316 -
download
1
Transcript of Yevgeniy Solodovnikov xcode instruments_usage
Xcode Instruments
Usage101
Eugene Solodovnykovhttp://idevblog.info
@sharpland
Instruments app purpose
Track down difficult-to-reproduce problems in your code
Do performance analysis on your program
Automate testing of your code
Stress-test parts of your application
Perform general system-level troubleshooting
Gain a deeper understanding of how your code works
Base templates
Leaks
Uses console leaks application (man leaks will explain you everything)
A lot of applications contain leaks. Our target is to avoid leaks in our applications :)
Quick example – Droplr application
Allocations
Count each allocation in your application’s session
May help with memory leaks even if Leaks instrument doesn’t see them
Quick example – Hex Fiend application
Hex Fiend dissection
Choose Hex Fiend application as a target
Run Leaks and Allocations instruments
Create a new window and close it (5-7 times)
Leaks just keep silence while Allocations instrument displays constant chart growth
Problem analyzing
Yeah, it’s difficult
Use heapshots
- init { [super init]; lineCountingRepresenter = [[HFLineCountingRepresenter alloc] init]; hexRepresenter = [[HFHexTextRepresenter alloc] init]; asciiRepresenter = [[HFStringEncodingTextRepresenter alloc] init]; scrollRepresenter = [[HFVerticalScrollerRepresenter alloc] init]; layoutRepresenter = [[HFLayoutRepresenter alloc] init]; //is missed in representers statusBarRepresenter = [[HFStatusBarRepresenter alloc] init]; dataInspectorRepresenter = [[DataInspectorRepresenter alloc] init]; [[hexRepresenter view] setAutoresizingMask:NSViewHeightSizable]; [[asciiRepresenter view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; ... return self;}
- (NSArray *)representers { return [NSArray arrayWithObjects:lineCountingRepresenter, hexRepresenter, asciiRepresenter, scrollRepresenter, dataInspectorRepresenter, statusBarRepresenter, nil];}
- (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [[self representers] makeObjectsPerformSelector:@selector(release)];
...
[super dealloc];}
And leaks won’t detect it
Time Profiler
Periodically stops the app and records the stack trace.
Allows to determine where execution time was spent
Can we do more?
Different pre-defined instruments
DTrace-based custom instruments
Mix them!
To be continued...