From owner-freebsd-hackers Mon Oct 21 2:25:47 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8C12F37B401 for ; Mon, 21 Oct 2002 02:25:45 -0700 (PDT) Received: from cse.cs.huji.ac.il (cse.cs.huji.ac.il [132.65.16.30]) by mx1.FreeBSD.org (Postfix) with ESMTP id 08A1443E42 for ; Mon, 21 Oct 2002 02:25:45 -0700 (PDT) (envelope-from danny@cs.huji.ac.il) Received: from pampa.cs.huji.ac.il ([132.65.80.32] ident=danny) by cse.cs.huji.ac.il with esmtp id 183Yoh-0009TR-00 for freebsd-hackers@FreeBSD.ORG; Mon, 21 Oct 2002 11:25:43 +0200 X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: freebsd-hackers@FreeBSD.ORG Subject: malloc Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 21 Oct 2002 11:25:43 +0200 From: Danny Braniss Message-Id: Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG the attached program - which shows the 'efficiancy' of our scientific programmers - tickled my curiosity. if compiled under Linux, it would run fine on FreeBSD 4.7-stable. compiled on FreeBSD it would bomb. so i fixed some kernel values (options MAXDSIZ="(2*1024*1024*1024)") and it run to complition, but: fbsd compiled: complex-2 took 23.652872 seconds, mem used=800000000(762M) linux : complex-2 took 11.969896 seconds, mem used=800000000(762M) comments? danny #include #include #include int MAX_N, mem; int main(int argc , char ** argv){ int i; int ** arr; struct timeval t1, t2; if(argc > 1) MAX_N = atoi(argv[1]); else MAX_N = 100000000; gettimeofday(&t1, 0); mem = sizeof (int *) * MAX_N; arr = malloc(mem); if(arr == NULL) { perror("Malloc"); exit(1); } for (i = 0 ; i < MAX_N ; ++i ){ arr[i] = malloc(sizeof(int)); if(arr[i] == NULL) { perror("malloc2"); printf("failed at %d, mem=%d(%d)\n", i, mem, mem/(1024 * 1024)); exit(1); } *arr[i] = i; mem += sizeof(int); } gettimeofday(&t2, 0); printf ("%s took %f seconds, mem used=%d(%dM)\n", getenv ("HOST"), t2.tv_sec-t1.tv_sec + (t2.tv_usec-t1.tv_usec)/(float)(1000000), mem, mem / (1024 * 1024)); for (i = 0 ; i < MAX_N ; ++i ){ if(*arr[i] != i) printf("GUEVALT! %d] %d\n", i, *arr[i]); } exit(0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message