Re: vfprintf() has a 4096-byte memory leak?

From: Poul-Henning Kamp <phk_at_phk.freebsd.dk>
Date: Sat, 02 Aug 2003 13:23:21 +0200
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.
Received on Sat Aug 02 2003 - 02:23:38 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:17 UTC