leaks
命令行工具将报告:
- 泄漏内存的地址
- 泄漏的大小(以字节为单位)
- 泄漏缓冲区的内容
如下所示:
Process: checker [84357]
Path: /path/to/program
Load Address: 0x104703000
Identifier: checker
Version: ???
Code Type: X86-64
Parent Process: zsh [64610]
Date/Time: 2019-11-30 18:43:06.864 -0800
Launch Time: 2019-11-30 18:42:58.593 -0800
OS Version: Mac OS X 10.13.4 (17E199)
Report Version: 7
Analysis Tool: /usr/bin/leaks
Physical footprint: 300K
Physical footprint (peak): 300K
----
leaks Report Version: 3.0
Process 84357: 161 nodes malloced for 17 KB
Process 84357: 3 leaks for 64 total leaked bytes.
Leak: 0x7fdf5b400350 size=16 zone: DefaultMallocZone_0x10470e000
Leak: 0x7fdf5b4027c0 size=16 zone: DefaultMallocZone_0x10470e000
Leak: 0x7fdf5b402810 size=32 zone: DefaultMallocZone_0x10470e000
我的问题是,我如何利用这些信息来实际跟踪并找到源代码中哪些malloc调用没有对应的free()调用? 我如何找出源文件/源文件中的位置? 我是否需要更改一些环境变量的值,例如MallocStackLogging或MallocStackLoggingNoCompact?
man leaks
。https://www.unix.com/man-page/osx/1/leaks/ - ABC