2
私はPythonのconcurrent.futures.ThreadPoolExecutor
を使用すると、vmsのメモリ使用量(psutilによって報告されたもの)が劇的に増加することがわかりました。なぜconcurrent.futuresがvmsメモリを増やすのですか?
In [1]: import psutil
In [2]: psutil.Process().memory_info().vms/1e6
Out[2]: 360.636416
In [3]: from concurrent.futures import ThreadPoolExecutor
In [4]: e = ThreadPoolExecutor(20)
In [5]: psutil.Process().memory_info().vms/1e6
Out[5]: 363.15136
In [6]: futures = e.map(lambda x: x + 1, range(100))
In [7]: psutil.Process().memory_info().vms/1e6
Out[7]: 1873.580032
In [8]: e.shutdown()
In [9]: psutil.Process().memory_info().vms/1e6
Out[9]: 1722.51136
これはスレッドの数に多少比例するようです。
'rss'のような他のメモリ属性は、より控えめな値を返します – MRocklin