SlideShare uma empresa Scribd logo
1 de 15
Baixar para ler offline
Xcode
Instruments
   Usage
    101
  Eugene Solodovnykov
   http://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...

Mais conteúdo relacionado

Mais de DneprCiklumEvents

Convert estimates to plans (Maxym Mykhalchuk Ciklum)
Convert estimates to plans (Maxym Mykhalchuk Ciklum)Convert estimates to plans (Maxym Mykhalchuk Ciklum)
Convert estimates to plans (Maxym Mykhalchuk Ciklum)DneprCiklumEvents
 
Vladimir kozhayev handmade isometry
Vladimir kozhayev handmade isometryVladimir kozhayev handmade isometry
Vladimir kozhayev handmade isometryDneprCiklumEvents
 
Pavel yuriychuk svg in game development
Pavel yuriychuk svg in game developmentPavel yuriychuk svg in game development
Pavel yuriychuk svg in game developmentDneprCiklumEvents
 
Vitaly hit' abc_of_game_development
Vitaly hit' abc_of_game_developmentVitaly hit' abc_of_game_development
Vitaly hit' abc_of_game_developmentDneprCiklumEvents
 
04 net saturday eugene sukhikh ''the basic performance questions''
04 net saturday eugene sukhikh ''the basic performance questions''04 net saturday eugene sukhikh ''the basic performance questions''
04 net saturday eugene sukhikh ''the basic performance questions''DneprCiklumEvents
 
04 net saturday eugene sukhikh ''the basic performance questions''
04 net saturday eugene sukhikh ''the basic performance questions''04 net saturday eugene sukhikh ''the basic performance questions''
04 net saturday eugene sukhikh ''the basic performance questions''DneprCiklumEvents
 
06 net saturday eugene zharkov ''silverlight. to oob or not to oob''
06 net saturday eugene zharkov ''silverlight. to oob or not to oob''06 net saturday eugene zharkov ''silverlight. to oob or not to oob''
06 net saturday eugene zharkov ''silverlight. to oob or not to oob''DneprCiklumEvents
 
03 net saturday anton samarskyy ''document oriented databases for the .net pl...
03 net saturday anton samarskyy ''document oriented databases for the .net pl...03 net saturday anton samarskyy ''document oriented databases for the .net pl...
03 net saturday anton samarskyy ''document oriented databases for the .net pl...DneprCiklumEvents
 
02 net saturday roman gomolko ''mvvm in javascript using knockoutjs''
02 net saturday roman gomolko ''mvvm in javascript using knockoutjs''02 net saturday roman gomolko ''mvvm in javascript using knockoutjs''
02 net saturday roman gomolko ''mvvm in javascript using knockoutjs''DneprCiklumEvents
 
01 net saturday alex krakovetskiy ''asp.net scaffolding''
01 net saturday alex  krakovetskiy ''asp.net scaffolding''01 net saturday alex  krakovetskiy ''asp.net scaffolding''
01 net saturday alex krakovetskiy ''asp.net scaffolding''DneprCiklumEvents
 
Sergey Khlopenov tools for_development_cross_platform_mobile_ap
Sergey Khlopenov tools for_development_cross_platform_mobile_apSergey Khlopenov tools for_development_cross_platform_mobile_ap
Sergey Khlopenov tools for_development_cross_platform_mobile_apDneprCiklumEvents
 
Segey Glebov tips and tricks for modern mobile project management
Segey Glebov tips and tricks for modern mobile project managementSegey Glebov tips and tricks for modern mobile project management
Segey Glebov tips and tricks for modern mobile project managementDneprCiklumEvents
 

Mais de DneprCiklumEvents (12)

Convert estimates to plans (Maxym Mykhalchuk Ciklum)
Convert estimates to plans (Maxym Mykhalchuk Ciklum)Convert estimates to plans (Maxym Mykhalchuk Ciklum)
Convert estimates to plans (Maxym Mykhalchuk Ciklum)
 
Vladimir kozhayev handmade isometry
Vladimir kozhayev handmade isometryVladimir kozhayev handmade isometry
Vladimir kozhayev handmade isometry
 
Pavel yuriychuk svg in game development
Pavel yuriychuk svg in game developmentPavel yuriychuk svg in game development
Pavel yuriychuk svg in game development
 
Vitaly hit' abc_of_game_development
Vitaly hit' abc_of_game_developmentVitaly hit' abc_of_game_development
Vitaly hit' abc_of_game_development
 
04 net saturday eugene sukhikh ''the basic performance questions''
04 net saturday eugene sukhikh ''the basic performance questions''04 net saturday eugene sukhikh ''the basic performance questions''
04 net saturday eugene sukhikh ''the basic performance questions''
 
04 net saturday eugene sukhikh ''the basic performance questions''
04 net saturday eugene sukhikh ''the basic performance questions''04 net saturday eugene sukhikh ''the basic performance questions''
04 net saturday eugene sukhikh ''the basic performance questions''
 
06 net saturday eugene zharkov ''silverlight. to oob or not to oob''
06 net saturday eugene zharkov ''silverlight. to oob or not to oob''06 net saturday eugene zharkov ''silverlight. to oob or not to oob''
06 net saturday eugene zharkov ''silverlight. to oob or not to oob''
 
03 net saturday anton samarskyy ''document oriented databases for the .net pl...
03 net saturday anton samarskyy ''document oriented databases for the .net pl...03 net saturday anton samarskyy ''document oriented databases for the .net pl...
03 net saturday anton samarskyy ''document oriented databases for the .net pl...
 
02 net saturday roman gomolko ''mvvm in javascript using knockoutjs''
02 net saturday roman gomolko ''mvvm in javascript using knockoutjs''02 net saturday roman gomolko ''mvvm in javascript using knockoutjs''
02 net saturday roman gomolko ''mvvm in javascript using knockoutjs''
 
01 net saturday alex krakovetskiy ''asp.net scaffolding''
01 net saturday alex  krakovetskiy ''asp.net scaffolding''01 net saturday alex  krakovetskiy ''asp.net scaffolding''
01 net saturday alex krakovetskiy ''asp.net scaffolding''
 
Sergey Khlopenov tools for_development_cross_platform_mobile_ap
Sergey Khlopenov tools for_development_cross_platform_mobile_apSergey Khlopenov tools for_development_cross_platform_mobile_ap
Sergey Khlopenov tools for_development_cross_platform_mobile_ap
 
Segey Glebov tips and tricks for modern mobile project management
Segey Glebov tips and tricks for modern mobile project managementSegey Glebov tips and tricks for modern mobile project management
Segey Glebov tips and tricks for modern mobile project management
 

Último

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 

Último (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Yevgeniy Solodovnikov xcode instruments_usage

  • 1. Xcode Instruments Usage 101 Eugene Solodovnykov http://idevblog.info @sharpland
  • 2. 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
  • 4.
  • 5. 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
  • 6.
  • 7. 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
  • 8. 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
  • 9.
  • 10. Problem analyzing Yeah, it’s difficult Use heapshots
  • 11. - 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
  • 12. Time Profiler Periodically stops the app and records the stack trace. Allows to determine where execution time was spent
  • 13.
  • 14. Can we do more? Different pre-defined instruments DTrace-based custom instruments Mix them!