Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Jul 2006 17:02:06 +0200 (CEST)
From:      "P.U.Kruppa" <root@pukruppa.de>
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        "P.U.Kruppa" <root@pukruppa.de>, freebsd-questions@freebsd.org
Subject:   Re: [OT] gcc: maximum length of an array?
Message-ID:  <20060727165348.C84312@www.pukruppa.net>
In-Reply-To: <20060723180502.GA14027@gothmog.pc>
References:  <20060724200535.G84312@www.pukruppa.net> <20060723180502.GA14027@gothmog.pc>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 23 Jul 2006, Giorgos Keramidas wrote:

> On 2006-07-24 20:49, "P.U.Kruppa" <root@pukruppa.de> 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 *
*********************************************



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060727165348.C84312>