When viewing the multi-process documentation, I saw a description that the memory of the child process created by os.fork() or mutiprocess and the main process have a copy on write mechanism, which means that the child process will copy the memory of the main process.
Because the document I saw was on Linux, I tested it on Windows.
Read a larger document in the main process and then create the process, and directly create the child process.
After comparison, only one of the processes has larger memory usage.
Excuse me, will Python copy the memory of the main process when creating a sub-process in Windows? If copying occurs, at which step does it occur? Create a subprocess, start a subprocess, or copy on write? Are there any books that explain the various uses of python in more detail and systematically?
Copy-on-write (COW)
is only for thefork
implementation, but inwindows
it is directlyCreateProcess
, which should not happen. For details, you can Google the principle and implementation ofCreateProcess
, as well You can refer to the following link:Creating a process under windows, detailed explanation and usage of CreateProcess()