From owner-freebsd-questions Sat Nov 11 9:25:17 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mercury.ccmr.cornell.edu (mercury.ccmr.cornell.edu [128.84.231.97]) by hub.freebsd.org (Postfix) with ESMTP id 6621437B479 for ; Sat, 11 Nov 2000 09:25:14 -0800 (PST) Received: from dragon.ccmr.cornell.edu (IDENT:0@dragon.ccmr.cornell.edu [128.84.231.182]) by mercury.ccmr.cornell.edu (8.9.3/8.9.3) with ESMTP id MAA10301; Sat, 11 Nov 2000 12:25:12 -0500 Received: from localhost (mitch@localhost) by dragon.ccmr.cornell.edu (8.9.3/8.9.3) with ESMTP id MAA16694; Sat, 11 Nov 2000 12:25:11 -0500 X-Authentication-Warning: dragon.ccmr.cornell.edu: mitch owned process doing -bs Date: Sat, 11 Nov 2000 12:25:11 -0500 (EST) From: Mitch Collinsworth To: freebsd-questions@freebsd.org Cc: Mitch Collinsworth Subject: Linux malloc better on FreeBSD than FreeBSD malloc? Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Well I hope that subject was provocative enough to generate some interest! :-) Here's a strange situation that's bugging me. I recently changed jobs, into a dept that's heavily Linux-based. I of course have different preferences, but need to demonstrate technical superiority if any changes are going to happen. An opportunity just arose to make some comparisons between Linux and FreeBSD in maximum process size. We have some new systems with 4 GB RAM each that will be made available for running large batch jobs. We have a very simple test program that malloc's successively larger and larger blocks of memory until it fails, freeing the current blocks after each successful trial. The strange thing is that the test program runs much farther on FreeBSD using the Linux binary in compatibility mode than it does using the binary compiled on FreeBSD! Included below are the output from each binary and the source. Can anyone explain these results? A second question, which is the primary issue we were trying to discover is if it is possible for a single process to malloc more than 2 GB of memory. FreeBSD supposedly supports up to 4 GB (on Intel hardware), but does anyone know if there is still a 2 GB per process limit? And if a single process can be larger than 2 GB, is there a 2 GB limit on any single malloc with that process? For comparison purposes, the Linux answers to these questions are that with a special "bigmem" patch installed, a process can be larger than 2 GB, but any single malloc is still limited to 2 GB. The system the tests are being run on is a 900 MHz Xeon running FreeBSD 4.1-R with 1 GB RAM and 18 GB swap: ruby> swapinfo -k Device 1K-blocks Used Avail Capacity Type /dev/da0s3b 511872 0 511872 0% Interleaved /dev/rda1c 17783108 0 17783108 0% Interleaved Total 18294980 0 18294980 0% ------FreeBSD results--------- # with FreeBSD compiled binary ruby> ./grab-fbsd Allocated f 268435455 Punt g at 268435455 # with Linux compiled binary run in compatibility mode ruby> ./grab-linux Allocated f 268435455 Allocated g 268435455 Allocated f 536870911 Allocated g 536870911 Allocated f 805306367 Allocated g 805306367 Allocated f 1073741823 Allocated g 1073741823 Allocated f 1342177279 Punt g at 1342177279 ------source----------------- #include #include #include int main(int argc, char *argv[]){ unsigned long i, s2; char *foo, *goo; for (i=1; i<100; i++){ foo = (char *) malloc(s2=(unsigned long)i*(1024*1024*256)-1); if ( foo == NULL) { printf("Punt f at %lu\n", s2); exit(1); } else { printf("Allocated f %lu\n",s2); } goo = (char *) malloc(s2=(unsigned long)i*(1024*1024*256)-1); if ( goo == NULL) { printf("Punt g at %lu\n", s2); exit(1); } else { printf("Allocated g %lu\n",s2); } sleep(4); free(foo); free(goo); } } ----------------------------- Thanks for any help. Please cc: me on replies. I'm no longer getting -questions directly. -Mitch To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message