From owner-freebsd-questions@FreeBSD.ORG Tue Jul 25 17:14:50 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 4537516A5AC for ; Tue, 25 Jul 2006 17:14:39 +0000 (UTC) (envelope-from root@pukruppa.de) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id B2D9F43D49 for ; Tue, 25 Jul 2006 17:14:38 +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=mrelayeu5) with ESMTP (Nemesis), id 0ML25U-1G5QUO0z48-0005vJ; Tue, 25 Jul 2006 19:14:36 +0200 Date: Thu, 27 Jul 2006 15:50:09 +0200 (CEST) From: "P.U.Kruppa" X-X-Sender: root@www.pukruppa.net To: Andrew Brampton In-Reply-To: <009d01c6ae6f$ec017840$0a00a8c0@Andrew> Message-ID: <20060727154218.W84312@www.pukruppa.net> References: <20060724200535.G84312@www.pukruppa.net> <009d01c6ae6f$ec017840$0a00a8c0@Andrew> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Provags-ID: kundenserver.de abuse@kundenserver.de login:2446dbdf8275641f979193ced594c629 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: Tue, 25 Jul 2006 17:14:50 -0000 On Sun, 23 Jul 2006, Andrew Brampton wrote: > Can you show me the line you are using to malloc with, and the lines you are > using to access the array... > > The smallest unit you can malloc on is a byte, and if you are mallocing > 100000000 bytes, and using each byte as a single boolean value then you are > wasting 7/8 of your array. > > It might be better to do some bit masking to gain access to the other 7 bits. Thanks for this idea Andrew! it took me some time to implement it - since I am quite a n00b and never heard about bitmasking - but with the help of http://c-faq.com/misc/bitsets.html I could do 10^9 . Uli. > > Andrew > > ----- Original Message ----- From: "P.U.Kruppa" > To: > Sent: Monday, July 24, 2006 7:49 PM > Subject: [OT] gcc: maximum length of an array? > > >> 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. >> >> So my questions: >> - is there some way to create a longer array? >> - or what are the alternatives? >> - do you know some kind of fine manual about this? >> >> Regards and thanks for all answers, >> >> Uli. >> >> >> ********************************************* >> * Peter Ulrich Kruppa - Wuppertal - Germany * >> ********************************************* >> _______________________________________________ >> 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 * *********************************************