As far as I know, I think that when you create new processes in the same pool, garbage collection is never performed, so you do not release memory from old processes, even if you finish using them. One fix would be forcing garbage collection in your while loop:
import time import multiprocessing import gc def process(): time.sleep(3) return def main(): pool = multiprocessing.Pool(processes=10) while 1: pool.apply_async(process) gc.collect() pool.close() pool.join() if __name__ == '__main__': main()
This fixed a memory leak for me as you force garbage collection before starting another set of processes. Hope someone can explain in more detail the cause of this memory leak.
source share