A multiprocessor module that displays memory for each child process in the same way as the main process.

I am using the python multiprocessor module and have some perplexities regarding the same.

Basically, I store some data initially in the main process, and it's about 16 GB (main memory size), as shown in the top command. I saved this data as global variables.

Then, multi-processor data processing is performed and processed accordingly and in different ways.

Now I see that multiprocessing is happening, i.e. all processes have their own CPU usage, but the memory of all processes is 16 GB each .. why. Shouldn't this use the same memory that I send via pass by reference to global variables .. Please think.

The output of the top command is as follows: -

PID USER PR NI VIRT RES SHR S% CPU% MEM TIME + COMMAND 13908 admin 20 0 16.7g 16 g 848 R 100.0 17.3 0: 32.92 python
13429 admin 20 0 16.7g 16g 3336 S 0.0 17.3 15 : 06.97 python
13910 admin 20 0 16.7g 16 g 848 R 100.3 17.3 0: 32.94 python
13911 admin 20 0 16.7g 16 g 840 R 100.0 17.3 0: 33.02 python
13912 admin 20 0 16.7g 16 g 836 R 99.6 17.3 0: 33.00 python
13907 admin 20 0 16.7g 16 g 796 R 100.0 17.3 0: 33.06 python
13909 admin 20 0 16.7 g 16g 796 R 99.6 17.3 0: 32.93 python

+1
source share
2 answers

Think of the multiprocessing module as syntactic sugar around os.fork ().

, fork? , , (, ..).

+2

, multiprocessing, . , , , , (, . ) . , (16,7 ) .

, "copy-on-write". , ​​ . , , . , , , , , . , , , 16 , .

multiprocessing (. " " http://docs.python.org/library/multiprocessing.html), ( , , . ).


footnote: , fork clone: ​​ , .
+2

Source: https://habr.com/ru/post/1664282/


All Articles