leaks
command-line tool will report
- the address of the leaked memory
- the size of the leak (in bytes)
- the contents of the leaked buffer
like the following:
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
My question is, how can I use these information to actually track down and find which malloc calls in my source code doesn’t have corresponding free()
calls?
How can I find out which source file / where in the source file?
Do I need to change the value of some environment variables like MallocStackLogging
or MallocStackLoggingNoCompact
?