From owner-freebsd-hackers Wed Dec 6 11: 9:37 2000 From owner-freebsd-hackers@FreeBSD.ORG Wed Dec 6 11:09:34 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from luxren2.boostworks.com (luxren2.boostworks.com [194.167.81.214]) by hub.freebsd.org (Postfix) with ESMTP id 406BA37B400 for ; Wed, 6 Dec 2000 11:09:32 -0800 (PST) Received: from boostworks.com (root@oldrn.luxdev.boostworks.com [192.168.1.99]) by luxren2.boostworks.com (8.9.1/8.9.1) with ESMTP id UAA31917; Wed, 6 Dec 2000 20:07:30 +0100 (CET) Message-Id: <200012061907.UAA31917@luxren2.boostworks.com> Date: Wed, 6 Dec 2000 20:07:07 +0100 (CET) From: Remy Nonnenmacher Reply-To: remy@boostworks.com Subject: Re: free() not freing pagedirs pages. To: phk@critter.freebsd.dk Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: <51350.976119810@critter> MIME-Version: 1.0 Content-Type: TEXT/plain; CHARSET=US-ASCII Sender: root@boostworks.com Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG OK. In fact my problem was just a printf that allocated a buffer via __smakebuf at the very last moment (when all memory was allocated). This prevent free() to give back all previous pages up to this one. The problem was _not_ in malloc.c. Anyway, i learned a lot from hacking the source to catch the caller. Thanks. RN. IhM On 6 Dec, Poul-Henning Kamp wrote: > In message <200012061612.RAA30340@luxren2.boostworks.com>, Remy Nonnenmacher wr > ites: > >>>From the /usr/src/lib/libc/stdlib/malloc.c sources, it seems that this >>is due to not shrinking/relocating pagedir pages (free_pages(), comment >>around line 940). This means that returning pages stop at first >>allocated pagedir. > > That is actually not correct. the pagedir is allocated with mmap > from anonymous memory and does not affect the sbrk(2)'ing. > >>It seems to be a problem also in some other Unixes, anyway, but i would >>like to know if: > > Presuming your question then is "can the pagedir be shrunk ?" the > answers are: > >>1) This is historical and must not be fixed. > > no. > >>2) This can be easily fixed. > > maybe. > >>3) Fixing it would lead to enormous problems. Better keep it like this. > > unlikely. > > Have you read the paper in src/share/doc/papers/malloc ? > > Also, if you are truly concerned with the returning to the OS of > memory, examine the 'H' option to phkmalloc. > > -- > 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. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message