From: John P Williams <jpw@zk3.dec.com>
Subject: Re: Third Degree reports memory leak within fopen?
Date: 1999/01/05 [thread overview]
Message-ID: <3692661C.DF6423E9@zk3.dec.com> (raw)
In-Reply-To: 76qhvv$rt9$1@nnrp1.dejanews.com
> When I run Thrid Degree on a simple program that contains a call
> to "fopen" on a Digital UNIX V4.0B (Rev. 564) machine, third degree
> reports a memory leak.
The fopen libc-call does allocate a small amount of memory which
it does not free. Third Degree cannot find a reference to that
memory after the program exits (perhaps erroneously, since its
algorithm can not accurately diagnose optimized code), so it reports
it as a "leak" instead of as a live "object".
In this particular case, the heap block is allocated at start up
and remains in use until program exit, so while it is certainly
heap memory that was not freed, it is not a case that you should
worry about because it does not hurt performance - in fact it is
designed this way in order to improve performance. We have no plans to
change this code or other libc code that leaves memory allocated until
the program exits, because the current code has better performance.
However, newer versions of Third Degree already suppress warnings
like this for system libraries, whose design and coding is often
sufficiently optimized as to cause reports like this one that
should always be ignored.
Even when your own code triggers reports of leaks or other bad things,
you need to consider the seriousness of the issue for the main goals
of your application. Leaking a heap block every time around a loop
is usually a serious problem, because the amount of memory lost is
proportional to the iteration count. But losing just 48 bytes at the end
of the program is not usually going to be a problem. If your application
really can't afford to leave 48 bytes allocated for the duration of its
execution, then it should probably not use the stdio package. You can use
both the leak-size and the leak-count as indicators of seriousness. A
single large leak early in the program might be a problem, but otherwise a
single leak at or near the end of the program is unlikely to be a problem.
I hope Third Degree is proving useful in analyzing your application.
We recommend analyzing only code that is compiled for debugging (with
the -g, -g1 or -g2 flags) though instrumenting libc is often worthwhile
to show up problems in the debuggable application code that calls it.
John P Williams, DIGITAL UNIX Development Environment Group, Compaq
prev parent reply other threads:[~1999-01-05 5:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-01-04 5:00 Third Degree reports memory leak within fopen? core__dump
1999-01-05 5:00 ` John P Williams [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox