Re: [MapViewOfFile] How to know the maximum number of bytes to map ?
- From: "Skywing" <skywing_NO_SPAM_@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 15 May 2006 09:51:44 -0400
There are a couple of things that can limit this:
- Available physical memory for system structures used to maintain the
mapped view (PTEs, etc).
- Available contiguous address space in the process.
I suspect that the latter is much more likely to be a constraining factor
for you on x86-based systems, unless the system is already under significant
memory pressure.
In a virgin process with correctly based DLLs, you have a bit under 2GB of
address space available on a typical x86 system with the default 2GB
user/2GB kernel address space split.
In WinDbg, the `!address' command is a good way to quickly check how much
free address space you have - this might be useful to run on some typical
usage configurations for your process to get a feel for what kind of size
range you might be looking for.
If you want to programmically calculate the amount of free address space,
you can call the VirtualQuery function iteratively over all address regions
returned by it and find the largest free region (starting at an allocation
granularity-aligned boundary, typically 64K).
Due to how mapped file views work, you don't necessarily need to have an
amount of physical/paged memory equal to the size of the file view you are
mapping. Data can be paged in/out of a mapped view similar in some respects
to how a paging file works, so you will not be, say, committing 2GB of
physical memory if you map a 2GB view of a file.
(Of course, if you are making a 2GB page-file-backed file mapping view,
then, yes you will consume 2GB of paging file quota.)
"Rodrigue" <rodrigue.roland@xxxxxxxxx> wrote in message
news:%23tHluW$dGHA.1276@xxxxxxxxxxxxxxxxxxxxxxx
Hello,
Could you tell me please how is it possible to know the maximum number of
bytes to map in the function MapViewOfFile ?
LPVOID MapViewOfFile(
HANDLE hFileMappingObject,
DWORD dwDesiredAccess,
DWORD dwFileOffsetHigh,
DWORD dwFileOffsetLow,
SIZE_T dwNumberOfBytesToMap
);
For the moment, I get the granularity of the system using the function
GetSytemInfo() and I use this value in MapViewOfFile (because
dwNumberOfBytesToMap has to be a multiple of the system granularity) but
after many tests I saw that it's possible to map a lot more memory...
Thanks in advance!
Cordially,
Rodrigue
.
- Follow-Ups:
- Re: [MapViewOfFile] How to know the maximum number of bytes to map ?
- From: anton bassov
- Re: [MapViewOfFile] How to know the maximum number of bytes to map ?
- References:
- Prev by Date: Re: GetCurrentProcessorNumber() for XP?
- Next by Date: Re: CreateFile with DELETE access
- Previous by thread: Re: [MapViewOfFile] How to know the maximum number of bytes to map ?
- Next by thread: Re: [MapViewOfFile] How to know the maximum number of bytes to map ?
- Index(es):
Relevant Pages
|