From owner-freebsd-questions@FreeBSD.ORG Tue Jul 25 18:08:29 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 E59AB16A4E1 for ; Tue, 25 Jul 2006 18:08:29 +0000 (UTC) (envelope-from root@pukruppa.de) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by mx1.FreeBSD.org (Postfix) with ESMTP id CE4DF43D67 for ; Tue, 25 Jul 2006 18:08:27 +0000 (GMT) (envelope-from root@pukruppa.de) Received: from [213.146.114.24] (helo=reverse-213-146-114-24.cust.kamp-dsl.de) by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis), id 0MKxQS-1G5RKN3REl-0000lf; Tue, 25 Jul 2006 20:08:20 +0200 Date: Thu, 27 Jul 2006 17:02:06 +0200 (CEST) From: "P.U.Kruppa" X-X-Sender: root@www.pukruppa.net To: Giorgos Keramidas In-Reply-To: <20060723180502.GA14027@gothmog.pc> Message-ID: <20060727165348.C84312@www.pukruppa.net> References: <20060724200535.G84312@www.pukruppa.net> <20060723180502.GA14027@gothmog.pc> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Provags-ID: kundenserver.de abuse@kundenserver.de login:2446dbdf8275641f979193ced594c629 Cc: "P.U.Kruppa" , 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: Tue, 25 Jul 2006 18:08:30 -0000 On Sun, 23 Jul 2006, Giorgos Keramidas wrote: > 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 :) *How* can I effectively split my array up? How can I access an element arr[n] if n is bigger than INT_MAX ? I have tried some kind of linear/linked list, but that becomes disgustingly slow. Thanks, Uli. > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > ********************************************* * Peter Ulrich Kruppa - Wuppertal - Germany * *********************************************