Direct leak of 4 byte(s) in 2 object(s) allocated from: #0 0x526a08 in operator new[](unsigned long) (/root/learn/cpp/cpp_leak_sample/main+0x526a08) #1 0x52aeda in main /root/learn/cpp/cpp_leak_sample/./main.cpp:21:19 #2 0x7f1ddf091554 in __libc_start_main (/lib64/libc.so.6+0x22554)
SUMMARY: AddressSanitizer: 4 byte(s) leaked in 2 allocation(s). [root@VM_0_13_centos cpp_leak_sample]# vim ./main.cpp [root@VM_0_13_centos cpp_leak_sample]# clang++ -D_GLIBCXX_DEBUG -g -o main -fsanitize=address -std=c++11 ./main.cpp [root@VM_0_13_centos cpp_leak_sample]# ./main
Direct leak of 4 byte(s) in 2 object(s) allocated from: #0 0x526f88 in operator new[](unsigned long) (/root/learn/cpp/cpp_leak_sample/main+0x526f88) #1 0x52b43f in leak_sample1() /root/learn/cpp/cpp_leak_sample/./main.cpp:24:19 #2 0x52b96a in main /root/learn/cpp/cpp_leak_sample/./main.cpp:63:5 #3 0x7f769f996554 in __libc_start_main (/lib64/libc.so.6+0x22554)
SUMMARY: AddressSanitizer: 4 byte(s) leaked in 2 allocation(s).
Direct leak of 5 byte(s) in 1 object(s) allocated from: #0 0x44f2de in malloc /usr/home/hacker/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:74 #1 0x464e86 in Baz() (/usr/home/hacker/a.out+0x464e86) #2 0x464fb4 in main (/usr/home/hacker/a.out+0x464fb4) #3 0x7f7e760b476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
## In all likelihood the jemalloc build you are using didn't have --enable-prof specified to the configurescript when it was built. You can verify this via the opt.stats_print mallctl to print out configuration information, or you can query config.prof directly.
leak 512 byte ==11344== Mismatched free() / delete / delete [] ==11344== at 0x483CFBF: operator delete(void*) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==11344== by 0x401428: leak_sample2() (cpp_leak_sample.cpp:69) ==11344== by 0x4014AA: main (cpp_leak_sample.cpp:84) ==11344== Address 0x4daa360 is 0 bytes inside a block of size 7 alloc'd ==11344== at 0x483C583: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==11344== by 0x401407: leak_sample2() (cpp_leak_sample.cpp:67) ==11344== by 0x4014AA: main (cpp_leak_sample.cpp:84) ==11344==