How can I determine if a compiled Objective-C app is using garbage collection?

前端 未结 2 2065
执笔经年
执笔经年 2021-02-20 12:57

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?

2条回答
  •  心在旅途
    2021-02-20 13:34

    Within the mach-o is a flag used to determine if a binary compiled with GC support, for non-GC, or mixed mode.

    I don't know of anything that queries these bits via a more friendly API.

    The markgc.c source within the Objective-C runtime can read said flags. You could refactor it to your needs, as desired.

    Kind of curious why you need to know?

提交回复
热议问题