vfprintf() has a 4096-byte memory leak?

Poul-Henning Kamp phk at phk.freebsd.dk
Sat Aug 2 04:23:38 PDT 2003


In message <3F2B9C59.3060209 at cytherianage.net>, "Ryan T. Dean" writes:
>Hey all-
>    I was doing some app debugging tonight, and noticed what appears to 
>be a memory leak in vfprintf().

This is probably the buffer which stdio uses for all I/O.

Try calling 
	setbuf(stdout, NULL);
	setbuf(stderr, NULL);

as the very first thing in your program, and you will probably see
that it does not allocate the 4k buffer, you may also be able to
measure the performance change due to this.

In other words, what you see is perfectly normal, and to be expected,
but if it is a problem for you, the above is the workaround.


	

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-current mailing list