From owner-freebsd-current Thu Aug 6 02:52:23 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id CAA05613 for freebsd-current-outgoing; Thu, 6 Aug 1998 02:52:23 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from implode.root.com (implode.root.com [198.145.90.17]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id CAA05608 for ; Thu, 6 Aug 1998 02:52:21 -0700 (PDT) (envelope-from root@implode.root.com) Received: from implode.root.com (localhost [127.0.0.1]) by implode.root.com (8.8.5/8.8.5) with ESMTP id CAA26488; Thu, 6 Aug 1998 02:48:58 -0700 (PDT) Message-Id: <199808060948.CAA26488@implode.root.com> To: Mark Huizer cc: freebsd-current@FreeBSD.ORG Subject: Re: memory leaks in libc In-reply-to: Your message of "Thu, 06 Aug 1998 10:08:59 +0200." <19980806100859.A312@xaa.iae.nl> From: David Greenman Reply-To: dg@root.com Date: Thu, 06 Aug 1998 02:48:58 -0700 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >Hi, a nice user of ours pointed me to the fact that various functions >like setenv, putenv etc leak memory like crazy. To mention a very >simple example: > >main(){while(1){setenv("A","AA",1);setenv("A","A",1);}} > >while consume all memory within short periods of time (see setenv.c for >the reason). > >Is this wellknown? I think it is bad, and would like to fix it The problem with fixing setenv() is that you don't know if a pointer was malloced, allocated from the env area above the stack, points to read-only text, points to a static data buffer, etc. There really is no way to know for sure, so you can't free the memory. -DG David Greenman Co-founder/Principal Architect, The FreeBSD Project To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message