Reputation: 1671
Where is the memory allocated? In which address space is the new memory?
Upvotes: 0
Views: 831
Reputation: 182883
There are two common types of shared memory in Windows.
One is when more than one process maps the same file into memory. This obviously occurs with executables and libraries, but it can also occur with data files. Basically, the fact that processes are sharing this memory has almost no effect on how it works. It is implemented through the same demand paging as would occur if a single process had it mapped.
The other type is a shared, anonymous mapping. These can be created by calling the CreateFileMapping function without specifying a valid file to map. This acts the same as if the memory was allocated, except that more than one process can access it. Just like normal memory usage, it can be paged to disk if it's not accessed or if RAM is needed for some other purpose.
For shared, anonymous mappings, the kernel gives processes a handle to the memory so that processes have a way to refer to it when they want to map it into their memory space.
Upvotes: 1