From owner-freebsd-current@FreeBSD.ORG Sat Aug 2 04:23:38 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 271BE37B401 for ; Sat, 2 Aug 2003 04:23:38 -0700 (PDT) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3FA3E43FA3 for ; Sat, 2 Aug 2003 04:23:37 -0700 (PDT) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.9/8.12.9) with ESMTP id h72BNLbS009869; Sat, 2 Aug 2003 13:23:34 +0200 (CEST) (envelope-from phk@phk.freebsd.dk) To: "Ryan T. Dean" From: "Poul-Henning Kamp" In-Reply-To: Your message of "Sat, 02 Aug 2003 07:11:21 EDT." <3F2B9C59.3060209@cytherianage.net> Date: Sat, 02 Aug 2003 13:23:21 +0200 Message-ID: <9868.1059823401@critter.freebsd.dk> cc: freebsd-current@freebsd.org Subject: Re: vfprintf() has a 4096-byte memory leak? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Aug 2003 11:23:38 -0000 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.