只有一个进程占用了所有内存

时间:2019-09-05 12:32:09

标签: python multiprocessing python-multiprocessing

我有以下形式的列表列表:

All_lists = [Arglist_1, ..., Arglist_N], 

"""
Arglist_i = [arg_i_1, ..., arg_i_k(i)]
arg_i_j is an argument for which I want to execute a target function "boo".

"""

我尝试为所有“独立”的Arglists运行功能“ boo”,并观察到只有一个进程占用了所有内存,并且系统中有很多可用内存-因此代码是按顺序处理的。 >

results_per_list = []
the_pool = multiprocessing.Pool(processes=mp.cpu_count(), initializer=...,initargs=...)
for arglist in All_lists:
   results = the_pool.map(boo,arglist) 
   results_per_list.append(results)
the_pool.close()
the_pool.join()

""" 
Then I'm using results_per_list to run some other functions 
"""

看着任务管理器,我观察到,除一个python.exe之外,其他所有存储器均占用50K内存和一个600K(平均)。

如何均匀分配任务,以便每个任务(或其中至少一些)占用相等的内存大小进行处理?

为什么现在正在发生的事是预期的行为?

谢谢

0 个答案:

没有答案
相关问题