CreateFileMapping之后,如何Release 这个Mapping , 并重新CreateFileMapping(大小不同)
CreateFileMapping之后,即使做了unMapViewOfFile 和CloseHandle,
好象这个Share memory 还在,用OpenFileMapping 还可以打开来读.
如何Release 这个Mapping , 并重新CreateFileMapping(大小不同)?
问题点数:0、回复次数:3Top
1 楼saucer(思归)回复于 2003-11-01 04:08:40 得分 0
you have to unmap all views, close all handles, from the documentation:
"...
To fully close a file mapping object, an application must unmap all mapped views of the file mapping object by calling UnmapViewOfFile, and close the file mapping object handle by calling CloseHandle
..."
also see
"Necessity of Unmapping All Views of a Mapped File"
http://support.microsoft.com/default.aspx?kbid=125713
you may have an unmapped file from previous try, consider to reboot your machine, and try again
Top
2 楼qli()回复于 2003-11-01 05:58:42 得分 0
Thanks,
although unmapped all views and closed all handles, the win2000 seams still hold the map registration. whatever reboot or not , the next time it is able to open and read again.
At first what I try to do is to change the size. it was successful by calling CreateFileMapping again.
Now what I worry about is that it seams the memory won't get released.All the information from the internet doesn't show how to release what the CreateFileMapping did. I am wondering that there would be some functions to do that which we don't know.Top
3 楼saucer(思归)回复于 2003-11-01 06:10:37 得分 0
I don't have C++ compiler at hand, so I cannot test it for you, but see
http://scv.bu.edu/SCV/Archive/IBM/IBMdocs/c/compiler/tasks/tumemex2.htm
Top




