Re: mmap(), MAP_SHARED, MAP_ANONYMOUS and sharing memory



Bahadir <Bilgehan.Balban@xxxxxxxxx> writes:
I have checked various unix specs and I am puzzled about how to share
memory between two processes using mmap().

AFAIK MAP_ANONYMOUS + MAP_PRIVATE would map /dev/zero (in linux man
pages don't mention /dev/zero) so the process can get some private
zero-initialised free memory, correct?

Before MAP_ANONYMOUS existed, the same effect could be accomplished on
'some operating system' (notably, Solaris) by mmap'ing /dev/zero.

Then what would MAP_ANONYMOUS + MAP_SHARED do?

Create a memory region shared among all processes created by the
process who mmap'ed it and all processes created by these processes
and ...

If Linux specifies no particular file for MAP_ANONYMOUS where would
the shared mapping be found by another process?

Not at all. To share memory among unrelated processing using mmap, one
would either use shm_open or mmap real files.
.



Relevant Pages

  • Re: StackOverflowException.
    ... The Status object monitors the ... so I'm really at a total loss as to where I'm leaking stack memory. ... private static extern bool EscapeCommFunction(IntPtr hFile, ... Good to know about arrays. ...
    (microsoft.public.dotnet.framework)
  • Re: How: multiple program instances sharing same data
    ... so this memory isn't shared. ... private copy of JITted code. ... Ok, because the .exe isn't native to my machine, it gets just-in-time ... I am talking about a Windows NET App, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How can I tell the application total memory usage? (LONG!)
    ... No you can't simply add these two to calculate the amount of memory your ... of memory taken by a process using the performance counters but you can get ... The "Private bytes" represents the total of the pages, ... So while might be important to keep an eye at your memory consumption, ...
    (microsoft.public.dotnet.languages.csharp)
  • Windows Service Memory Usage
    ... starts to the first time it hits the database its memory consumption is ... database for the first time its memory jumps to 15MB and stays there. ... private SqlConnection sqlConnection = null; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Memory leak with Datagrid and array
    ... > Matrix_A still has a reference to your instance of form2, ... > For detailed information on windows memory management ... > 64-bit, working set, private bytes, etc. ... >> However, the memory problem persists. ...
    (microsoft.public.dotnet.languages.vb)