在命令行上使用OSX Leaks for C程序? [英] Using OSX Leaks for C Programs on the Command Line?

查看:126
本文介绍了在命令行上使用OSX Leaks for C程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能给我任何简单的语法来运行OSX的leaks工具来检测已编译的C程序中的内存泄漏吗?我正在使用10.8,所以我遇到了valgrind的严重兼容性问题.

Can anyone give me any simple syntax for running OSX's leaks tool for detecting memory leaks in a compiled C program? I'm on 10.8, so I'm running into serious compatibility issues with valgrind.

我所读到的有关XCode泄漏/仪器的大多数内容都涉及到XCode环境中,而不是我想为我的C程序做的事情.

Most of the stuff I've read about XCode's Leaks/Instruments involves being in an XCode environment -- not something I want to do for my C programs.

有没有一种方法可以从命令行在已编译的C程序上运行泄漏?如果没有,在等待valgrind的更新版本时,我还可以使用其他可靠的替代方法,还是我必须使用Linux发行版来设置VM?

Is there a way I can just run leaks on a compiled C program from the command line? If not, are there any other reliable alternatives I can use while waiting for an updated version of valgrind, or do I have to set up a VM with a Linux distro?

推荐答案

使用iprofiler工具(

Use the iprofiler tool (manpage) by adding this to the start of your command line:

iprofiler -leaks -d $HOME/tmp

(其中$HOME/tmp是要写入结果的位置).

(where $HOME/tmp is where you want the results written).

然后您可以使用仪器打开生成的.dtps捆绑包以检查是否泄漏(或iprofiler执行的其他4种检查中的任何一项).

You can then open up the resulting .dtps bundle using Instruments to check for leaks (or any of the other 4 checks that iprofiler performs).

如果使用的是 clang ,则同时使用-O3-g进行编译(因为 clang 不支持-pg).

If you are using clang then compile with both -O3 and -g (as clang doesn't support -pg).

这篇关于在命令行上使用OSX Leaks for C程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆