"memory history" 命令到底是什么?

What exactly is the "memory history" command?

总结:我收到消息:

AddressSanitizer debugger support is active. Memory error breakpoint has been installed and you can now use it in the 'memory history' command.

什么是“memory history”命令,我该如何使用它?

详情:

什么意思,内存历史命令到底是什么?我该如何使用它?我进行了搜索,但没有找到任何可以回答我问题的内容。

Address Sanitizer 下的

运行 允许您查看对象是如何分配的。 memory history 命令需要一个 pointer/address,它将显示该对象是如何分配的(分配的历史堆栈跟踪):

(lldb) po self
<MasterViewController: 0x61800000e080>

(lldb) memory history 0x61800000e080
  thread ... name = 'Memory allocated at'
    frame #0: 0x00000001051bba97 libclang_rt.asan_iossim_dynamic.dylib`wrap_calloc + 199
    frame #1: 0x00000001064362fd libobjc.A.dylib`class_createInstance + 84
    frame #2: 0x0000000106440dc7 libobjc.A.dylib`_objc_rootAlloc + 41
    frame #3: 0x00000001072d6d25 UIKit`-[UIClassSwapper initWithCoder:] + 175
    frame #4: 0x00000001074c731b UIKit`UINibDecoderDecodeObjectForValue + 683
    ...

它甚至适用于已经解除分配的对象,它还显示解除分配回溯!当您不小心访问已释放的对象时,这非常有用。