Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 02 Aug 2003 13:23:21 +0200
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        "Ryan T. Dean" <rtdean@cytherianage.net>
Cc:        freebsd-current@freebsd.org
Subject:   Re: vfprintf() has a 4096-byte memory leak? 
Message-ID:  <9868.1059823401@critter.freebsd.dk>
In-Reply-To: Your message of "Sat, 02 Aug 2003 07:11:21 EDT." <3F2B9C59.3060209@cytherianage.net> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <3F2B9C59.3060209@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@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9868.1059823401>