*BSD News Article 63755


Return to BSD News archive

Newsgroups: comp.unix.bsd.freebsd.misc
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.eng.convex.com!newshost.convex.com!cs.utexas.edu!howland.reston.ans.net!ix.netcom.com!netcom.com!barbems
From: barbems@netcom.com (Barbara Snyder)
Subject: Re: Resource Limits
Message-ID: <barbemsDoEDs5.Aw9@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
X-Newsreader: TIN [version 1.2 PL1]
References: <4hmagl$mqf@gwdu19.gwdg.de>
Date: Sun, 17 Mar 1996 05:55:17 GMT
Lines: 27
Sender: barbems@netcom13.netcom.com

Konrad Heuer (kheuer@gwdg.de) wrote:
> With FreeBSD Release 2.1:
>
> After explicitly resetting the soft resource limits in
> /etc/profile and /etc/csh.login I observe that my test
> program gets only half of the memory defined by the data limit.
>
> The limits I use are (csh formulation):
>
> limit datasize       8192 kbytes

/* program that malloc's 1 meg, free's, 2 meg, free's, 3 meg, free's, etc */

2.1-RELEASE's malloc() is tuned for speed, not space optimization.  It
always allocates memory in powers of two internally. When you malloc 4 meg,
it adds a small bit of overhead, and requests an 8-meg chunk from the
system.  Since your program uses some small memory itself, the malloc goes
over the 8-meg limit and fails.  Try your program again, and malloc 1 meg at
a time (comment out the last two lines in your loop).  You'll be able to
allocate 7 meg. (don't ask me why it didn't round the 1-meg mallocs     .:,
up to two and fail on the fourth malloc; I don't know :)               - * -
                                                                        ':`
If you really need to malloc large blocks of memory more efficiently,  o   o
ftp the malloc.c out of 2.2-CURRENT/src/lib/libc/stdlib.  It can       |\^/|
malloc 6 meg using your original code.                                  \V/
                                                                        /_\
	-Dan Nelson                                                    _/ \_