How use Instruments and display the console in Command Lines applications

前端 未结 3 1644
粉色の甜心
粉色の甜心 2020-12-31 00:33

I\'m using Xcode on OSX to develop command line C applications. I would also like to use Instruments to profile and find memory leaks.

However, I couldn\'t find a wa

相关标签:
3条回答
  • 2020-12-31 00:56

    It's a little late to contribute to this old thread, however I have found the best way of profiling a command line utility is to use iprofiler (manpage). This allows data to be collected from the command line simply by adding this to the start of the command line:

    iprofiler -leaks -d $HOME/tmp
    

    (I have a private temporary directory at $HOME/tmp, so you might need to use /tmp or leave the -d command line option off altogether).

    My test scripts automatically add that to the command line if $FINDLEAKS is defined (and will prepend valgrind if running under Linux).

    This then generates a .dtps file (actually a directory) which can be loaded and anaylysed using Instruments.

    If you are compiling using clang then simply add both -O3 and -g (clang doesn't support the -pg command line option).

    0 讨论(0)
  • 2020-12-31 01:08

    It's easy. See the screenshot.

    screenshot

    0 讨论(0)
  • 2020-12-31 01:09

    You can change the output in the Options dropdown when choosing your target. The output will appear in the system Console (Applications/Utilities/Console).

    IO options

    0 讨论(0)
提交回复
热议问题