Question

I have a program that is creating a map file, its able to do that call just fine, m_hMap = CreateFileMapping(m_hFile,0,dwProtect,0,m_dwMapSize,NULL);, but when the subsequent function call to MapViewOfFile(m_hMap,dwViewAccess,0,0,0), I get an error code of 8, which is ERROR_NOT_ENOUGH_MEMORY, or error string "error Not enough storage is available to process this command".

So I'm not totally understanding what the MapViewOfFile does for me, and how to fix the situation.

some numbers...

m_dwMapSize = 453427200
dwProtect = PAGE_READWRITE;
dwViewAccess = FILE_MAP_ALL_ACCESS;

I think my page size is 65536

Was it helpful?

Solution

In case of very large file and to read it, it is recommended to read it in small pieces and then process each piece. And MapViewOfFile function is used to map a piece in memory.

Look at http://msdn.microsoft.com/en-us/library/windows/desktop/aa366761(v=vs.85).aspx need offset to do its job properly i.e. in case you want to read a very large file in pieces. Mostly due to fragmentation and related reason very large memory request fails.

OTHER TIPS

If you are working on a 64 bit processor then the system will allocate a total of 4GB memory with bit set LargeaddressAware. go to Configuration properties->linker->system. in Enable largeaddressware: check Yes /LARGEADDRESSAWARE and check.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top