Can Instruments be used using the command line?
Asked Answered
E

2

12

Can Instruments be used as a replacement for

valgrind

If one wants to check for memory leaks using instruments can it be used from the terminal?

Eyesight answered 27/1, 2011 at 16:29 Comment(1)
I'm also interested in the XCode 13 answer to this same question. We basically want to supervise a program run to get data like the cpu cycles used in the execution.Ropy
P
20

Instruments used to have a command line interface:

$ instruments -h

Example usage:

$ instruments -t mytemplate -a myapp.app

For leaks, try the Leaks.tracetemplate. To see all available templates, use -s.

There is another executable, just called leaks. You can inspect any running application by giving leaks its PID:

$ echo $$
620

$ leaks 620
leaks Report Version:  2.0 
Process:         bash [620]
Path:            /bin/bash
Load Address:    0x100000000
...
Process 620: 37983 nodes malloced for 1123 KB
Process 620: 0 leaks for 0 total leaked bytes.

Read more about leaks in the Apple developer reference library.

Paestum answered 27/1, 2011 at 16:39 Comment(4)
Do you know if it is possible to launch or attach UIAutomation tool to a process on the actual iOS device using Instruments command line interface ?Mannes
instruments -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate <full_path_to_application> -e UIASCRIPT <script.js> -e UIARESULTSPATH <output_results_path> Found on lemonjar.com/blog/?p=69Hairdo
-a options no longer exists. instruments, version 9.0 (63198) usage: instruments [-t template] [-D document] [-l timeLimit] [-i #] [-w device] [[-p pid] | [application [-e variable value] [argument ...]]]Fetiparous
This seems to be no longer true nowadays, at least I can't find this tool on a monterey macbook.Digress
F
2

For Xcode 9, if you want to profile a iOS app, an example command like this:

instruments -t Zombies -w 'iPhone SE (11.0.1) [XXX] (Simulator)' MyApp.app

instruments command ref:

https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Recording,Pausing,andStoppingTraces.html#//apple_ref/doc/uid/TP40004652-CH12-SW3

Fetiparous answered 21/1, 2018 at 23:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.