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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d02eb5c33ac65d9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-10 07:13:12 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Array and memory usage Date: 10 Mar 2003 07:13:12 -0800 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0303100713.7f7bcbb7@posting.google.com> References: NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1047309192 14374 127.0.0.1 (10 Mar 2003 15:13:12 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 10 Mar 2003 15:13:12 GMT Xref: archiver1.google.com comp.lang.ada:35128 Date: 2003-03-10T15:13:12+00:00 List-Id: Robert A Duff wrote in message news:... > > If you use this trick on Windows, it will allocate backing store for all > that virtual memory. I believe most Unix systems are smarter than that. > > This trick is sometimes more efficient than linked lists for growable > data structures. The links waste space, plus if you're not careful, the > list gets scattered all over the place, damaging cache behavior. The > nice thing about arrays is that they are contiguous. One thing you can on Windows is simply reserve the virtual memory for the array, without committing it to physical memory, and then use SEH ("structured exception handling") to handle the error. The SEH mechanism supports resumption semantics, so you can handle the exception by committing the page you need, and then resuming from the spot from where the exception was raised. This is documented in Jeff Richter's Programming Applications book.