Python 如何在多个进程之间共享内存?
How does Python share memory among multiple processes?
我读到进程在单独的内存空间上运行 (link)。然而,python 的多处理包提供了共享内存(multiprocessing.Value、multiprocessing.Array)。
- 这些数据存储在哪里(在哪个进程中)?
- 数据是否被子进程引用访问?
数据分配在通过 mmap
module. You can see the code here and here 创建的共享匿名内存映射中。
我读到进程在单独的内存空间上运行 (link)。然而,python 的多处理包提供了共享内存(multiprocessing.Value、multiprocessing.Array)。
- 这些数据存储在哪里(在哪个进程中)?
- 数据是否被子进程引用访问?
数据分配在通过 mmap
module. You can see the code here and here 创建的共享匿名内存映射中。