Date: Sat, 25 Mar 2006 10:41:30 +0100 From: des@des.no (Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?=) To: Jason Evans <jasone@FreeBSD.org> Cc: cvs-all@FreeBSD.org, cvs-src@FreeBSD.org, src-committers@FreeBSD.org, Julian Elischer <julian@elischer.org>, Peter Wemm <peter@FreeBSD.org> Subject: Re: cvs commit: src/lib/libc/sys mmap.2 Message-ID: <863bh6q2t1.fsf@xps.des.no> In-Reply-To: <442475D1.5010903@FreeBSD.org> (Jason Evans's message of "Fri, 24 Mar 2006 14:42:25 -0800") References: <200603232337.k2NNb6tH020675@repoman.freebsd.org> <86irq45etp.fsf@xps.des.no> <442444C4.8020404@elischer.org> <86k6ajpmvb.fsf@xps.des.no> <442475D1.5010903@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Jason Evans <jasone@FreeBSD.org> writes: > By choosing a malloc size of 1MB in your test program, you just > happened to pick the worst possible case for malloc chunk > fragmentation (50% utilization). In reality, the reason that you > hit a limit of 697 on i386 is that you used pretty much the entire > mmap()able address space (2*697MB =3D=3D 1394MB). On i386, jemalloc > switches from sbrk() to mmap() when heap space runs out. How about this, then, with malloc(1024): % ulimit -d 2097152 % ./allocate 2861145 kB % ulimit -d $((1024*1024)) % ./allocate 1861209 kB % ulimit -d $((512*1024)) % ./allocate 1361241 kB In all cases, it should stop when it reaches dsiz. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no --=-=-= Content-Disposition: attachment; filename=allocate.c /* * cc -Wall -pedantic -std=c99 -O2 -pipe -o allocate allocate.c */ #include <signal.h> #include <stdio.h> #include <stdlib.h> static volatile sig_atomic_t sig_caught; static void sig_handler(int sig) { sig_caught = sig; } int main(void) { int i = 0; signal(SIGINT, sig_handler); while (!sig_caught && malloc(1024) != NULL) { if (++i % 128 == 0) printf("\r%d MB", i / 1024); fflush(stdout); } printf("\r%d kB\n", i); if (sig_caught) printf("interrupted\n"); exit(0); } --=-=-=--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?863bh6q2t1.fsf>