Skip to content Skip to sidebar Skip to footer

Why Do Processes Spawned By The Multiprocessing Module Not Duplicate Memory?

My impression with python multiprocessing is that when you create a new process with multiprocessing.Process(), it creates an entire copy of your current program in memory and cont

Solution 1:

On Linux, forking a process doesn't result in twice the memory being occupied immediately. Instead, the page table of the new process will be set up to point to the same physical memory as the old process, and only if one of the processes attempts to do a write to one of the pages, they get actually copied (copy on write, COW). The result is that it appears that both processes have separate memory, but physical memory is only allocated once one of the process actually touches the memory.


Post a Comment for "Why Do Processes Spawned By The Multiprocessing Module Not Duplicate Memory?"