From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ccec7cf654f5e8c3 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!newscon02.news.prodigy.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: creating database Date: 09 May 2005 08:33:48 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <9cKdnRAx8IfEZOPfRVn-pg@comcast.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1115642029 1083 192.74.137.71 (9 May 2005 12:33:49 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 9 May 2005 12:33:49 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:10975 Date: 2005-05-09T08:33:48-04:00 List-Id: tmoran@acm.org writes: > > > don't know how many records there'll be so it seems inefficient to > > > declare an array of a particular size. > > > > Sensible thinking. > > ... > > Instead of allocating a fixed size array - which on unix systems isn't > > quite as bad an idea as it sounds - you can allocate and reallocate > A fixed array allocation may be the both the most efficient and the > simplest on a virtual memory system. The parts you don't use don't > occupy any physical space, just address space, and the OS's allocation > of physical space may well be difficult to beat in efficiency. But I believe that by default, on both Unix and Windows, the OS will allocate backing store (i.e. space in the paging file). That can be a problem for really huge arrays. To avoid that on Unix, use mmap with the NORESERVE flag, and map the file /dev/zero -- then you'll get allocate-on-write pages of virtual address space. On Windows, it's a bit more complicated: use VirtualAlloc to reserve pages, and then when you actually want to use them, use VirtualAlloc again to "commit" pages. - Bob