Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I was going through memory mapping file mechanism. Here I have a doubt regarding File mapping object. As mentioned in below link:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366542(v=vs.85).aspx[^]
It is mentioned that "The size of a file mapping object that is backed by a named file is limited by disk space."
So my question is that in any case we map file in physical memory so , isn't it like that the size of physical memory limits the maximum size of file mapping object.
What actually file mapping object is : whether it is clone of original file(in RAM) which is on disk or it is something like handle to that original file.
And what are the limiting factors of size of file mapping object.
One more line in the article is "Since it does not cost you any system resources to create a larger file mapping object", what does it mean as it seems to that when you create a file mapping object u are using physical memory.
Please explain all this and let me know in case i am not correct.

Thanks in advance.
Posted

1 solution

A memory mapped file acts as if it is in memory but actually is not. You can just use it like it is completely in memory while the OS tries to predict and has to fixup actual memory with locations of the file you read. It makes working with very large files easier for programmers because you don't have to worry about some part of the file is in memory or not. This is all handled by the OS. It does use physycal memory, but only a relative small window compared to the actual file size.

Good luck!
 
Share this answer
 
Comments
Rahul@puna 3-Jul-14 4:49am    
As you said , It does use physical memory, but only a relative small window compared to the actual size. But if we want we can map whole file to physical memory if that amount of memory is available. Am I correct?
One more thing why the referred article is saying that File mapping object does not cost us any system resources as physical memory is also a system resource. So what does that mean?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900