Article View: borland.public.cppbuilder.nativeapi
Article #6077Re: Thanks! and a General Reply For All.
From: Andrue Cope [TeamB]
Date: Tue, 14 Jun 2005 08:49
Date: Tue, 14 Jun 2005 08:49
62 lines
3783 bytes
3783 bytes
JD wrote: > Re-read Alan's posts to me. Actually that was me :) I've carried out some research this morning on Win2K and it has produced some definitive and interesting results. If you use new[] to ask for up to 80% of memory then: 1.Until you populate that memory nothing much happens. Windows is using lazy allocation as I expected. The VM (Virtual Memory) size increases but that's all. No physical RAM is consumed. 2.As you write to the array physical RAM is consumed to back the VM store. This is very important because of the next point; 3.You will only be given physical RAM up to the 80% limit of what's available as/when you access your address space. Actually you do get a bit more but it's temporary and rapidly gets reclaimed. 4.You get to keep whatever physical RAM you were given. As long as you *don't minimize your application* you get to keep the physical RAM being used to back your single allocation. What does this mean for the Deniel? It means that you want to have something like this at program startup: DWORD arraySize=physRAMAvail*0.8; BYTE * wibble=new BYTE[ arraySize ]; memset( wibble, arraySize, 0 ); This will give you what you want - 'physRAMAvail' bytes locked into memory without disk swapping. An important point however:If your application is minimized all bets are off and from my tests Windows will /severely/ trim your working set and page stuff out to disk. Some points: 1.'80%' is our guess. We didn't bother calculating it exactly. 2.I'm not sure what happens to the RAM you are given in scenario (3). I don't know if you get to keep 'the most you can be given' or if Windows stops trying to help you out. Basic conclusion:The Windows memory manager is actually trying to cooperate with Deniel's scenario. It has a pretty good idea what you are trying to do and as long as you make your intention clear from the start you stand a good chance of achieving what you want. I'd like to know how Linux handles this myself. It implies Windows Memory Manager has some intelligence but I still have a gut feeling that the older Unix strategy of taking RAM purely on demand is better. -- Andrue Cope [TeamB] [Bicester, Uk] http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<42ae9a20@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder1.cambrium.nl!feed.tweaknews.nl!38.119.66.181.MISMATCH!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42ab3793$1@newsgroups.borland.com> <gjmna117s71qnpihpbtg7sqmbbvaob90q6@4ax.com> <42abfa21$1@newsgroups.borland.com> <kdqoa11nmfhki6qcdmue2vt9poh235d958@4ax.com> <42ac9598$1@newsgroups.borland.com> <0fhpa19iu9nv8c4kalnej9mp85r2jm2irs@4ax.com> <42ad5684$1@newsgroups.borland.com> <renqa1t8i9e0glhhereu7tj4u0mekqqrfk@4ax.com> <lrbra1te6a0k6pg39bt8u46hb471ndmn6u@4ax.com> <42adf900$1@newsgroups.borland.com> <42ae5114$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,93efc3d53d15c3e4 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Andrue Cope [TeamB]" <no.spam@not.a.valid.address> Subject: Re: Thanks! and a General Reply For All. Newsgroups: borland.public.cppbuilder.nativeapi References: <42ab3793$1@newsgroups.borland.com> <gjmna117s71qnpihpbtg7sqmbbvaob90q6@4ax.com> <42abfa21$1@newsgroups.borland.com> <kdqoa11nmfhki6qcdmue2vt9poh235d958@4ax.com> <42ac9598$1@newsgroups.borland.com> <0fhpa19iu9nv8c4kalnej9mp85r2jm2irs@4ax.com> <42ad5684$1@newsgroups.borland.com> <renqa1t8i9e0glhhereu7tj4u0mekqqrfk@4ax.com> <lrbra1te6a0k6pg39bt8u46hb471ndmn6u@4ax.com> <42adf900$1@newsgroups.borland.com> <42ae5114$1@newsgroups.borland.com> Date: Tue, 14 Jun 2005 09:49:40 +0100 User-Agent: XanaNews/1.17.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 NNTP-Posting-Host: 217.207.223.34 Message-ID: <42ae9a20@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1118738976 217.207.223.34 (14 Jun 2005 01:49:36 -0700) Lines: 62 X-Authenticated-User: acope Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder1.cambrium.nl!feed.tweaknews.nl!38.119.66.181.MISMATCH!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail