【问题标题】:Can Instruments be used using the command line?可以使用命令行使用 Instruments 吗?
【发布时间】:2011-06-16 16:21:48
【问题描述】:

乐器可以代替

valgrind

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

【问题讨论】:

    标签: c xcode instruments


    【解决方案1】:

    仪器有命令行界面:

    $ instruments -h
    

    示例用法:

    $ instruments -t mytemplate -a myapp.app
    

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

    还有另一个可执行文件,名为leaks。你可以通过给leaks它的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.
    

    详细了解 Apple 开发人员 reference library 中的泄漏。

    【讨论】:

    • 您知道是否可以使用 Instruments 命令行界面启动或附加 UIAutomation 工具到实际 iOS 设备上的进程?
    • instruments -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -e UIASCRIPT -e UIARESULTSPATH 发现于lemonjar.com/blog/?p=69
    • -一个选项不再存在。仪器,版本 9.0 (63198) 用法:仪器 [-t 模板] [-D 文档] [-l timeLimit] [-i #] [-w 设备] [[-p pid] | [应用[-e变量值] [参数...]]]
    【解决方案2】:

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

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

    仪器命令参考:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-23
      • 2013-07-14
      • 2021-04-11
      • 1970-01-01
      • 1970-01-01
      • 2012-06-03
      • 2016-05-28
      • 1970-01-01
      相关资源
      最近更新 更多