🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #6040

Re: How to Make Sure that Buffer use ONLY memory

#6040
From: Deniel
Date: Sun, 12 Jun 2005 20:05
85 lines
4300 bytes
>Way not?
>See "Requirements/Client" at
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/virtualalloc.asp

Thanks, i read in this site also but i did not see that page 
and the example code in it, i'll check it again now.


>That's still pretty vague.
>How big is the data set?
>Assume you had a MegaTerra Byte of RAM.
>How much would you need?

It's realy a hard question for me at this stage, i still have
to think about it and do some calculatings to know that, all
i know at this point is that i'll have to use several buffers
that i'll fill with data from a file, and while the program is
running i continuously have to read data from this buffer, do
some calculations and return the results to the buffer, and i
have to do this process again and again and again for a VERY
long time (several mounths i guess) until getting the final 
results, if i could i would use even 2 GB of memory, but again,
i can't tell you for sure at this point, i just know that i 
want to use ONLY 'real' memory, not hard-drive memory (paging).


>If your calculating proceeds in an orderly manner through the data
>(sequential, or nearly so rather than truely random), then you might
>have 2 threads. 1 thread calculating and updating the data, the other
>thread anticipating the data about-to-be-needed, and reading that off
>disk (Reading in chunks is, of course, better that per-double)
>Double-buffering, in that thread 1 is reading/calculating/updating one
>buffer while thread 2 is saving/retrieving the next bit.

I'm not sure that it's fits to my situation, i have to read 
several data values from the buffer, do some calculates with
them, and then change the data in that buffer accordingly, it's
not 2 processes that can be done on parallel.


>>>You might also want to check out CreateFileMapping and MapViewOfFile
>
>It's not just for memory sharing.
>Use it for it's intended purpose: Virtual Memory.
>It eliminates the file reading/writing from your code.
>The O/S takes care of that.

Does CreateFileMapping let me allocate 150 MB buffer in the
'real' memory, and make sure it will not use the hard-disk?


>If it is small enough for FileMapping, I'd likely go with that as it
>would be simplest.

How much memory can i allocate using FileMapping? and does it
force the system to allocate ONLY 'real' memory without paging?


>If I was still concerned about the speed

Yes, i'm VERY concerned about the speed here, and i'm also 
concerned about wear and tear my hard drive, and if i'll run
my application for several mounths continuesly that's what can
happen, that's also why i want to use ONLY real memory, becouse
it can't be wear and tear by lot of reading and writing.
 

, I'd add a visible progress
>device that updates less than 1 per second (visual updates are slow)
>so I could time it.
>Then add VirtualAlloc code (more complicated) and retest.
>As for disk reads...if you can get a minute of calculation out of a 1
>second disk read, i wouldn't sweat it as you are talking 1/2 day of
>disk delay per month of calculation.

I did not understood what you where saying here. 


>If you are running on a laptop with a slow drive, consider using a
>desktop, or adding an external USB disk drive.

No, i'm using a desktop PC.

Dani.
Technical Details
Message-ID: <42ac9598$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <42ab3793$1@newsgroups.borland.com> <gjmna117s71qnpihpbtg7sqmbbvaob90q6@4ax.com> <42abfa21$1@newsgroups.borland.com> <kdqoa11nmfhki6qcdmue2vt9poh235d958@4ax.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: How to Make Sure that Buffer use ONLY memory 
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 62.0.172.65     
References: <42ab3793$1@newsgroups.borland.com> <gjmna117s71qnpihpbtg7sqmbbvaob90q6@4ax.com> <42abfa21$1@newsgroups.borland.com> <kdqoa11nmfhki6qcdmue2vt9poh235d958@4ax.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <42ac9598$1@newsgroups.borland.com>
Date: 12 Jun 2005 13:05:44 -0700
X-Trace: newsgroups.borland.com 1118606744 207.105.83.66 (12 Jun 2005 13:05:44 -0700)
Lines: 86
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail