From owner-freebsd-questions@FreeBSD.ORG Sun Jul 23 18:05:32 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD0EB16A4DE for ; Sun, 23 Jul 2006 18:05:32 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6AA5543D68 for ; Sun, 23 Jul 2006 18:05:26 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.pc (host5.bedc.ondsl.gr [62.103.39.229]) (authenticated bits=128) by igloo.linux.gr (8.13.7/8.13.7/Debian-1) with ESMTP id k6NI58xt012963 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 23 Jul 2006 21:05:12 +0300 Received: from gothmog.pc (gothmog [127.0.0.1]) by gothmog.pc (8.13.7/8.13.7) with ESMTP id k6NI53Os038923; Sun, 23 Jul 2006 21:05:04 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.pc (8.13.7/8.13.7/Submit) id k6NI53IG038908; Sun, 23 Jul 2006 21:05:03 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Sun, 23 Jul 2006 21:05:03 +0300 From: Giorgos Keramidas To: "P.U.Kruppa" Message-ID: <20060723180502.GA14027@gothmog.pc> References: <20060724200535.G84312@www.pukruppa.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060724200535.G84312@www.pukruppa.net> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (score=-3.76, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.64, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: freebsd-questions@freebsd.org Subject: Re: [OT] gcc: maximum length of an array? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Jul 2006 18:05:32 -0000 On 2006-07-24 20:49, "P.U.Kruppa" wrote: > Hi, > > sorry for posting an [OT], but usually people on this list know > everything :-) > > Since I don't know too much about programming I am frequently > fascinated by simple things like Eratosthenes' sieve. As you might > remember, one has to create a boolean array for that. The longer the > array the more primes can be found. > > With malloc() I can create an array of length 100000000 (10^8) and the > first 5761455 primes are calculated in a few seconds. So of course I > would like to test length 10^9 but here my program crashes. If this is about integer values, which are probably 32-bit, you are hitting the kern.maxdsiz limit of 512 MB. An array of 100,000,000 32-bit values takes up 4 * 100,000,000 = 400,000,000 (close to 400 MiB of memory to store). Anything above 512 MB in size will make the data size of your program so big that it will overflow the data seg size: $ ulimit -a core file size (blocks, -c) unlimited data seg size (kbytes, -d) 524288 ... You can either increase kern.maxdsiz in your `/boot/loader.conf' file, or redesign the algorithm to work with larger datasets by splitting them in chunks that you can still process with 512 MB of data :)