开发者

Appending to MemoryMappedFile?

Maybe I've misunderstood something fundamentally about how memory mapped files work but, how do I append to the end of a file when I'm using MemoryMappedFile? t开发者_运维技巧he CreateViewAccessor only allows me to create a view of the file current's capacity

I could write to the end using the underlying FileStream instead but doesn't that kind of defeat the purpose of using MemoryMapping? (I thought it would cache and write to disk the appending as well). Another option is to cache writes and read from the cache rather than the memory stream for appended data.

Just wondering what the common practice is for working with memory-mapped file's that's growing so I'm not reinventing the wheel yet again


You cannot change the size once created the memory maps. You can specify the size when creating the map. see http://msdn.microsoft.com/en-us/library/dd987389.aspx

Memory mapping is some kind of advanced i/o technique. You should not use it unless (1) it is required by native library; (2) you need random access in performance critical environment. In either case, you should not use it without understanding the native (machine-level) implication.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜