xcode 可以使用命令行使用 Instruments 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4819000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:08:59  来源:igfitidea点击:

Can Instruments be used using the command line?

cxcodeinstruments

提问by system

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?

如果想使用仪器检查内存泄漏,可以从终端使用吗?

回答by miku

Instruments has a command line interface:

Instruments 有一个命令行界面:

$ instruments -h

Example usage:

用法示例:

$ instruments -t mytemplate -a myapp.app

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

对于泄漏,请尝试Leaks.tracetemplate. 要查看所有可用模板,请使用-s.

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

还有另一个可执行文件,只是称为leaks. 您可以通过提供leaks其 PID来检查任何正在运行的应用程序:

$ ps aux | grep "[b]ash" | awk '{print }'
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.

在 Apple 开发人员参考库中阅读有关泄漏的更多信息。

回答by Bill Chan

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

对于 Xcode 9,如果您想分析 iOS 应用程序,请使用如下示例命令:

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

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