Home  >  Q&A  >  body text

Is there a copy of the main process in the memory of the windows python subprocess?

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?

高洛峰高洛峰2686 days ago853

reply all(1)I'll reply

  • 滿天的星座

    滿天的星座2017-06-12 09:25:56

    Copy-on-write (COW) is only for the fork implementation, but in windows it is directly CreateProcess, which should not happen. For details, you can Google the principle and implementation of CreateProcess, as well You can refer to the following link:
    Creating a process under windows, detailed explanation and usage of CreateProcess()

    reply
    0
  • Cancelreply