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

前端 未结 2 1644
醉酒成梦
醉酒成梦 2021-02-20 12:55

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:28

    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?

提交回复
热议问题