本文介绍了我如何确定一个编译的Objective-C应用程序是否使用垃圾收集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我在Mac上的任何应用程序,有没有办法告诉它是否已经启用GC编译,或者是否正在进行手动内存管理?

For any application that I have on my Mac, is there a way to tell if it was compiled with GC enabled, or if it's doing manual memory management?

推荐答案

我发现了答案。请注意,原始讯息是,但包含发表评论,这是一位苹果工程师,指明了方向。

I found the answer here. Mind you that the original post is wrong, but contains a comment by Mark Rowe, an Apple engineer, that points the way.

我已经重新运行它在当前操作系统(10.6.4)的机器上提到的 otool 命令。以下是输出:

I have re-run the otool commands he mentions on my machine with the current OS (10.6.4). Here's the output:


$ uname -a
Darwin meaningless.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386

### Mail doesn't use GC
$ otool -oV /Applications/Mail.app/Contents/MacOS/Mail | tail -3
Contents of (__DATA,__objc_imageinfo) section
  version 0
    flags 0x0

### Xcode supports GC and retain/release
$ otool -oV /Developer/Applications/Xcode.app/Contents/MacOS/Xcode | tail -3
Contents of (__DATA,__objc_imageinfo) section
  version 0
    flags 0x2 OBJC_IMAGE_SUPPORTS_GC

这篇关于我如何确定一个编译的Objective-C应用程序是否使用垃圾收集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 08:37