Article View: borland.public.cppbuilder.nativeapi
Article #5983Re: Thanks! and a General Reply For All.
From: Deniel
Date: Tue, 14 Jun 2005 21:56
Date: Tue, 14 Jun 2005 21:56
99 lines
4744 bytes
4744 bytes
Thanks Very Much Andrue! (and to all!) Your points here will help me a lot, thanks very much for checking it for me, i appreciate it very much! By the way i was sitting on my application today and i developed it some more, and maybe i will not have to use so much memory as i was thinking that i will need! :-) Anyway, After i write this - DWORD arraySize = physRAMAvail * 0.8; BYTE * wibble = new BYTE[ arraySize ]; memset( wibble, arraySize, 0 ); and if i don't minimized my application - can i be sure that all the cells of the arraySize[] array will be locked into the physical memory without disk swapping? even if i don't read or write the buffer or to some of it's cells for a while? You said that i have to allocate not more then 80% of the avalible physical memory (RAM), does this code gives me the value of AVAILABLE (free) physical RAM? GlobalMemoryStatus( &ms ); physRAMAvail = ms.dwAvailPhys; Well, i got to go working on my application now :-) I'm very excited!! Dani. "Andrue Cope [TeamB]" <no.spam@not.a.valid.address> wrote: >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:
<42af5273$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!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> <42ae9a20@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: "Deniel" <DenielMail@Internet.com> Sender: "Deniel" <DenielMail@Internet.com> Reply-To: "Deniel" <DenielMail@Internet.com> Subject: Re: Thanks! and a General Reply For All. Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 217.132.134.52 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> <42ae9a20@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <42af5273$1@newsgroups.borland.com> Date: 14 Jun 2005 14:56:03 -0700 X-Trace: newsgroups.borland.com 1118786163 207.105.83.66 (14 Jun 2005 14:56:03 -0700) Lines: 100 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail