@@ -33,10 +33,10 @@ the output, after a couple of minutes, will look something like this:
3333
3434<pre >
3535hello: Now: 287; Backtraces: 77; allocations: 650036; total memory: 83,709,180 bytes.
36- backtrace 50 (value_n: 104636.00); [ 178, 238>( 60): 25957 allocations (1375222 total, 1.9%), size 3311982; 432.62 allocations/s, 55199 bytes/s
37- backtrace 50 (value_n: 104636.00); [ 55, 178>( 123): 52722 allocations (2793918 total, 1.9%), size 6734135; 428.63 allocations/s, 54749 bytes/s
38- backtrace 49 (value_n: 58296.00); [ 178, 238>( 60): 14520 allocations (1382814 total, 1.1%), size 1860716; 242.00 allocations/s, 31011 bytes/s
39- backtrace 49 (value_n: 58296.00); [ 55, 178>( 123): 29256 allocations (2794155 total, 1.0%), size 3744938; 237.85 allocations/s, 30446 bytes/s
36+ backtrace 44 (value_n: 104636.00); [ 178, 238>( 60): 25957 allocations (1375222 total, 1.9%), size 3311982; 432.62 allocations/s, 55199 bytes/s
37+ backtrace 44 (value_n: 104636.00); [ 55, 178>( 123): 52722 allocations (2793918 total, 1.9%), size 6734135; 428.63 allocations/s, 54749 bytes/s
38+ backtrace 41 (value_n: 58296.00); [ 178, 238>( 60): 14520 allocations (1382814 total, 1.1%), size 1860716; 242.00 allocations/s, 31011 bytes/s
39+ backtrace 41 (value_n: 58296.00); [ 55, 178>( 123): 29256 allocations (2794155 total, 1.0%), size 3744938; 237.85 allocations/s, 30446 bytes/s
4040</pre >
4141
4242Showing two intervals here: from 55 seconds after start till 178 seconds after start,
@@ -49,26 +49,26 @@ allocations between brackets. Finally the total amount of leaked memory
4949in bytes, and the number of leaks in allocations and bytes per second
5050is given.
5151
52- As you can see in this example, backtrace 50 leaks about twice as much as backtrace 49 .
53- In fact, backtrace 49 doesn't really leak at all (it just naturally causes the heap
54- to grow in the beginning), but backtrace 50 does (deliberately) have a bug that causes
52+ As you can see in this example, backtrace 44 leaks about twice as much as backtrace 41 .
53+ In fact, backtrace 41 doesn't really leak at all (it just naturally causes the heap
54+ to grow in the beginning), but backtrace 44 does (deliberately) have a bug that causes
5555leaking on top of that.
5656
5757We can print both backtraces from ` memleak_control ` with the commands,
5858
5959<pre >
60- libmemleak> dump 49
61- #0 00007f84b862d33b in malloc at /home/carlo/projects/libmemleak/libmemleak-objdir/src/../../libmemleak/src/memleak.c:1008
62- #1 00000000004014da in do_work(int)
63- #2 000000000040101c in thread_entry0(void*)
64- #3 00007f84b7e7070a in start_thread
65- #4 00007f84b7b9f82d in ?? at /build/glibc-Qz8a69 /glibc-2.23 /misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:111
66- libmemleak> dump 50
67- #0 00007f84b862d33b in malloc at /home/carlo/projects/libmemleak/libmemleak-objdir/src/../../libmemleak/src/memleak.c:1008
68- #1 00000000004014da in do_work(int)
69- #2 0000000000401035 in thread_entry1(void*)
70- #3 00007f84b7e7070a in start_thread
71- #4 00007f84b7b9f82d in ?? at /build/glibc-Qz8a69 /glibc-2.23 /misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:111
60+ libmemleak> dump 41
61+ #0 00007f5ab45dc860 in malloc
62+ #1 0000563e4f6b4592 in do_work(int) at /home/carlo/projects/libmemleak/libmemleak/src/hello.cc:157
63+ #2 0000563e4f6b4070 in thread_entry0(void*) at /home/carlo/projects/libmemleak/libmemleak/src/hello.cc:19
64+ #3 00007f5ab3e176db in start_thread at /build/glibc-OTsEL5/glibc-2.27/nptl/pthread_create.c:463
65+ #4 00007f5ab3b3988f in ?? at /build/glibc-OTsEL5 /glibc-2.27 /misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97
66+ libmemleak> dump 44
67+ #0 00007f5ab45dc860 in malloc
68+ #1 0000563e4f6b4592 in do_work(int) at /home/carlo/projects/libmemleak/libmemleak/src/hello.cc:157
69+ #2 0000563e4f6b408d in thread_entry1(void*) at /home/carlo/projects/libmemleak/libmemleak/src/hello.cc:20
70+ #3 00007f5ab3e176db in start_thread at /build/glibc-OTsEL5/glibc-2.27/nptl/pthread_create.c:463
71+ #4 00007f5ab3b3988f in ?? at /build/glibc-OTsEL5 /glibc-2.27 /misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97
7272</pre >
7373
7474So apparently the leak is caused by a call from ` thread_entry1() ` .
0 commit comments