6

I read that processes operate on seperate memory spaces (link). However the multiprocessing package of python offers shared memory (multiprocessing.Value, multiprocessing.Array).

  • Where (in which process) is this data stored?
  • Is the data accessed by reference by the child processes?
4
  • it does not matter. Commented Jun 17, 2017 at 18:42
  • 1
    Perhaps the question should be, "How does Python share memory among multiple processes?" But to your specific questions, it has to be in the heap. It is not in any process space. When Python starts each process, it has to look at the declared shared variables and create memory space and references (answer to second question) in the heap. When a process uses it, the multiprocessing module does all of the memory locking to prevent data corruption, etc. There's a lot more to it than that, but that's the basics. Commented Jun 17, 2017 at 18:54
  • 1
    This is also different depending on platform (for example windows) Commented Jun 17, 2017 at 19:29
  • It's not Python, it's the operating system service. e.g. shared memory. Commented Jun 17, 2017 at 20:01

1 Answer 1

4

The data is allocated in a shared, anonymous memory map created through the mmap module. You can see the code here and here.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.