text
stringlengths 0
234
|
---|
#include <stdlib.h> |
#include <stdio.h> |
int |
main(int argc, char *argv[]) |
{ |
mtrace(); |
for (int j = 0; j < 2; j++) |
malloc(100); /* never freed\-\-a memory leak */ |
calloc(16, 16); /* never freed\-\-a memory leak */ |
exit(exit_success); |
} |
.ee |
.in |
.pp |
when we run the program as follows, we see that |
.br mtrace () |
diagnosed memory leaks at two different locations in the program: |
.pp |
.in +4n |
.ex |
.rb "$ " "cc \-g t_mtrace.c \-o t_mtrace" |
.rb "$ " "export malloc_trace=/tmp/t" |
.rb "$ " "./t_mtrace" |
.rb "$ " "mtrace ./t_mtrace $malloc_trace" |
memory not freed: |
-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- |
address size caller |
0x084c9378 0x64 at /home/cecilia/t_mtrace.c:12 |
0x084c93e0 0x64 at /home/cecilia/t_mtrace.c:12 |
0x084c9448 0x100 at /home/cecilia/t_mtrace.c:16 |
.ee |
.in |
.pp |
the first two messages about unfreed memory correspond to the two |
.br malloc (3) |
calls inside the |
.i for |
loop. |
the final message corresponds to the call to |
.br calloc (3) |
(which in turn calls |
.br malloc (3)). |
.sh see also |
.br mtrace (1), |
.br malloc (3), |
.br malloc_hook (3), |
.br mcheck (3) |
.sh colophon |
this page is part of release 5.13 of the linux |
.i man-pages |
project. |
a description of the project, |
information about reporting bugs, |
and the latest version of this page, |
can be found at |
\%https://www.kernel.org/doc/man\-pages/. |
.so man3/rpc.3 |
.\" copyright 1993 david metcalfe ([email protected]) |
.\" and copyright 2008, linux foundation, written by michael kerrisk |
.\" <[email protected]> |
.\" |
.\" %%%license_start(verbatim) |
.\" permission is granted to make and distribute verbatim copies of this |
.\" manual provided the copyright notice and this permission notice are |
.\" preserved on all copies. |
.\" |
.\" permission is granted to copy and distribute modified versions of this |
.\" manual under the conditions for verbatim copying, provided that the |
.\" entire resulting derived work is distributed under the terms of a |
.\" permission notice identical to this one. |
.\" |
.\" since the linux kernel and libraries are constantly changing, this |
.\" manual page may be incorrect or out-of-date. the author(s) assume no |
.\" responsibility for errors or omissions, or for damages resulting from |
.\" the use of the information contained herein. the author(s) may not |
.\" have taken the same level of care in the production of this manual, |
.\" which is licensed free of charge, as they might when working |
.\" professionally. |
.\" |
.\" formatted or processed versions of this manual, if unaccompanied by |
.\" the source, must acknowledge the copyright and authors of this work. |
.\" %%%license_end |
.\" |
.\" references consulted: |
.\" linux libc source code |
.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) |
.\" 386bsd man pages |
.\" modified 1993-07-24 by rik faith ([email protected]) |
.\" modified 2002-07-25 by walter harms |
.\" ([email protected]) |
.\" |
.th acos 3 2021-03-22 "" "linux programmer's manual" |
.sh name |
acos, acosf, acosl \- arc cosine function |
.sh synopsis |
Subsets and Splits