From owner-freebsd-questions@FreeBSD.ORG Wed Apr 30 10:23:32 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35D18106564A for ; Wed, 30 Apr 2008 10:23: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 A86408FC2A for ; Wed, 30 Apr 2008 10:23:31 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (adsl62-8.kln.forthnet.gr [77.49.189.8]) (authenticated bits=128) by igloo.linux.gr (8.14.2/8.14.2/Debian-4) with ESMTP id m3UAN6Pm032540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 30 Apr 2008 13:23:15 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id m3UAN62Z002658; Wed, 30 Apr 2008 13:23:06 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id m3UAMvJc002657; Wed, 30 Apr 2008 13:22:57 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: "Edward Ruggeri" References: <919383240804291737k513360bcje6c4c85dc4621903@mail.gmail.com> Date: Wed, 30 Apr 2008 13:22:57 +0300 In-Reply-To: <919383240804291737k513360bcje6c4c85dc4621903@mail.gmail.com> (Edward Ruggeri's message of "Tue, 29 Apr 2008 20:37:12 -0400") Message-ID: <87k5ifljzy.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-MailScanner-ID: m3UAN6Pm032540 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.908, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.49, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: FreeBSD Questions Subject: Re: Dynamic Memory Allocation Limit? 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: Wed, 30 Apr 2008 10:23:32 -0000 On Tue, 29 Apr 2008 20:37:12 -0400, "Edward Ruggeri" wrote: > I have recently been writing an implementation of the sieve of > Eratosthenes in C. To find all primes less than N, I dynamically > create an array of chars (relatively small datatype) of length N+1 (I > know I don't need to represent evens). > > Everything works great up until around 600 million, at which case > memory allocation fails. At this point, I am asking for 600M chars, > which is about 572MB (I might be failing to take account of offset?). You are hitting the limit set as kern.maxdsiz (512 MB by default). One possible 'optimization', which can bump the total count of numbers you can represent in your sieve (at a small cost of extra complexity) is to use a single *bit* for each number, and the macros from FreeBSD's . By using a bit-map for the numbers, you can represent eight times as many numbers in a sieve of the same size. Another option is to bump the value of kern.maxdsiz at boot time. This has been described many many times in the list archives, so a Google search should quickly yield several hits. > I am using FreeBSD 6.3-prerelease, with SMP for a Athlon X2 4200+ (if > it makes a difference). Sorry if this is a RTFM question ... That's fine. A question never asked is much worse than a question which causes people to learn even more about FreeBSD :)