Article View: borland.public.cppbuilder.nativeapi
Article #7554Re: Preventing memory block from swapping to disk
From: Bob Gonder
Date: Wed, 19 Jan 2005 18:41
Date: Wed, 19 Jan 2005 18:41
33 lines
2490 bytes
2490 bytes
Tumurbaatar S. wrote: >I need to lock several MB of memory in RAM. I had read some topics >of Win32 Ref, but somethings are not clear for me: >1. Global/LocalAlloc() with GMEM_FIXED is enough to get a non-swappable >memory block? No, they are swapable. GMEM_FIXED just means they are not discardable. Discardable means the OS can toss them without actually saving. >2. Or I need VirtualAlloc() with MEM_COMMIT and VirtualLock()? Yes, VirtualLock is the only way to ensure non-swapable. >3. Because VirtualLock() can lock only a small portion of memory (30 * 4K), >I have to SetProcessWorkingSetSize(), but how to determine a minimum >working set size for the process? Memory I need + X..., how much more? Use GetProcessWorkingSetSize to find out how much you get by default, then adjust from there. >5. The memory I need to lock, is used to store a large sorted list with >many items in it and new items are constantly added/removed from the list. >Also values of items also changes constantly. "Constantly" means that >I expect up to 1000 requests (for add/remove/change) per second. >Because my program so often access this memory block (whole memory >block, not some portion of it), will system keep it in RAM by default? The OS checks for "least-used" pages to swap, so if you are hitting all of the pages regularly, then some other processes' memory might be of lower priority, and so swapped instead of yours, but no guarantee.
Technical Details
Message-ID:
<ss8tu01rseektarkq0l147mu08jqe0b9ua@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41ee1494@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,c5b636ba1001447d X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Preventing memory block from swapping to disk Date: Wed, 19 Jan 2005 10:41:30 -0800 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <ss8tu01rseektarkq0l147mu08jqe0b9ua@4ax.com> References: <41ee1494@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 69.69.91.123 X-Trace: newsgroups.borland.com 1106160087 69.69.91.123 (19 Jan 2005 10:41:27 -0800) Lines: 36 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail