MapViewOfFile返回的p是系统预留(reserve)的进程内的地址空间, 每Map一次,就预留一块地址,直到显式调用UnMapViewOfFile或进程结束(被操作系统资源回收)。 所以是的, 如果不取消映射, 迟早会没有足够的空间地址供预留。 具体你看参看一下MSDN或Jeffrey Richter写的Windows via C/C++一书, 其中提到: You must remember to call UnmapViewOfFile. If you do not call this function, the reserved region won't be released until your process terminates. Whenever you call MapViewOfFile, the system always reserves a new region within your process' address space—any previously reserved regions are not released. 又: 你可以每次映射不同的段(同一文件的同一个映射对象),这些不同的MapView的内容是协同的,当然最后还是要UnMap一下的,有始有终,成堆出现,这本来就是一个好的程序所应具备的起码的风格。
Windows API学习(一)MapViewOfFile后一定要UnMapViewOfFile
最新推荐文章于 2024-01-18 17:28:59 发布