CreateFileMapping Question
From: Bruce Kingsley (brucek5_at_mindspring.com)
Date: 05/21/04
- Next message: Jeff Partch [MVP]: "Re: ? Resetting CListCtrl color [flag] to (default) system color scheme"
- Previous message: Polaris: "Re: How to convert char array into wchar array?"
- Next in thread: Joseph M. Newcomer: "Re: CreateFileMapping Question"
- Reply: Joseph M. Newcomer: "Re: CreateFileMapping Question"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 21 May 2004 02:38:29 GMT
All:
I have a question about the use of CreateFileMapping functions. See example
below...
First Process:
HANDLE hmem = ::CreateFileMapping((HANDLE) 0xFFFFFFFF, NULL,
PAGE_READWRITE, 0, FileSize, FM_SCOPEMAPFILENAME);
FileBuffer = (SampleTransferType*)::MapViewOfFile(hmem, FILE_MAP_WRITE, 0,
0, FileSize);
// Fill FileBuffer here....
::UnmapViewOfFile(FileBuffer);
::CloseHandle(hmem);
Second Process:
HANDLE hmem = ::OpenFileMapping(FILE_MAP_WRITE, FALSE, FM_ADCMAPFILENAME);
FileBuffer = (SampleTransferType*)::MapViewOfFile(hmem, FILE_MAP_WRITE, 0,
0, FileSize);
// FileBuffer is read here...
::UnmapViewOfFile(FileBuffer);
::CloseHandle(hmem);
All works, but I'm concerned about memory leaks. This code is repeatably
used and I wonder what frees the memory used by these functions? The first
process closes all it's handles before the second process opens the memory
file, so I know the memory is still be held. When the first process is
called again and calls CreateFileMapping with the same name, does it re-use
the same memory, or does it allocate even more memory?
-- Regards; Bruce Kingsley
- Next message: Jeff Partch [MVP]: "Re: ? Resetting CListCtrl color [flag] to (default) system color scheme"
- Previous message: Polaris: "Re: How to convert char array into wchar array?"
- Next in thread: Joseph M. Newcomer: "Re: CreateFileMapping Question"
- Reply: Joseph M. Newcomer: "Re: CreateFileMapping Question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|