Hi Mark, Mark Kettenis wrote on Fri, Dec 25, 2015 at 12:30:43PM +0100: > [email protected] wrote:
>> it looks like there is a memory leak in libc. In file >> "src/lib/libc/stdio/makebuf.c" line 62 malloc(3) is called, but >> never freed, when printf(3) is called. > Not really a leak. That buffer gets freed when fclose() gets called. > However we don't do that in the cleanup handler. I don't know why, > but the commented out code in stdio/findfp.c:_cleanup() suggests > somebody considered doing so at some point. Chris Torek in 1990: https://svnweb.freebsd.org/csrg/lib/libc/stdio/findfp.c?r1=35686&r2=46074 In the commit message, Keith Bostic doesn't say why he considered it, or why he decided not to. Right before exiting, free(3) is optional, sometimes it adds clarity. But in an atexit(3) handler, it's probably better to only do the minimum required for correct operation, so i tend to think that not calling fclose(3) here is actually better. Yours, Ingo
