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,be7fa91648ac3f12 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!news.tele.dk!not-for-mail Sender: malo@0x535ddc81.boanxx18.adsl-dhcp.tele.dk Newsgroups: comp.lang.ada Subject: Re: Large arrays (again), problem case for GNAT References: From: Mark Lorenzen User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Date: 15 Apr 2005 20:30:20 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: TDC Totalloesninger NNTP-Posting-Host: 83.93.220.129 X-Trace: 1113589821 dtext01.news.tele.dk 181 83.93.220.129:57332 X-Complaints-To: abuse@post.tele.dk Xref: g2news1.google.com comp.lang.ada:10502 Date: 2005-04-15T20:30:20+02:00 List-Id: Robert A Duff writes: > "Dmitry A. Kazakov" writes: > > > On 14 Apr 2005 11:18:22 -0400, Robert A Duff wrote: > > > > > The reason I like allocate-on-write is that it is very useful to > > > allocate a huge array, and then only use some part of it. That way, the > > > program can deal with enormous input data, without paying the cost when > > > the input data is small. Physical memory is 1000 times more expensive > > > than address space. > > > > I think this approach is flawed. The contract of malloc is to return memory > > not the address space. > > Well, I'm not an expert on malloc. Where is it documented that this is > the contract? Apparently the Linux folks don't think that's the > contract. Exactly. As mentioned in another post, it is a popular implementation strategy to only allocate memory on write in order to save the system from memory exhaustion. > > I *am* an expert on Ada, and I know that "new" does not necessarily > reserve real memory -- it might just reserve address space. > > >...That must be just another system call. > > I agree that there *should* be two separate calls: one reserves address > space, and the other reserves real memory. Or one call with a Boolean > parameter. A simple "man malloc" specifies that the default overcommitting behaviour can be turned of by writing the letter "2" to the file /proc/sys/vm/overcommit_memory . F.x.: echo 2 > /proc/sys/vm/overcommit_memory - Mark Lorenzen