【发布时间】:2021-07-02 03:06:09
【问题描述】:
我有一个获取一些 id 的进程,并基于这些 id,我从数据库中获取(熊猫)数据帧,经过一些处理后,数据帧使用 to_csv 存储到文件系统,然后使用 @ 删除数据帧987654321@.
数据帧的获取和处理是使用 ThreadPoolExecutor 完成的。
with futures.ThreadPoolExecutor(max_workers=number_of_workers) as executor:
return list(executor.map(func, args))
func 是流程,args 是客户 ID。
尽管 del 和线程预计会结束,但我看到内存使用仍然存在,我的预感是数据帧仍然存在于内存中。
我怎样才能清理内存..??
PS:我也试过 gc...没用
【问题讨论】:
标签: python multithreading memory-management memory-leaks threadpoolexecutor