数据帧列表卡在内存中

时间:2017-11-10 21:00:22

标签: python ipython jupyter-notebook

我通过以下方式构建数据框列表:

def compute_list_of_comprehensive_SP_series(instrument_now):
    series_now = normalized_price_history[instrument_now].copy()
    series_now.name = series_now.name + "_Settle"
    comprehensive_SP_series = compute_comprehensive_time_series_pd_based_on_time_series_now(series_now,MA_list_to_consider, resample_to_day = False)
    return comprehensive_SP_series

list_of_comprehensive_SP_series =  []
for j in to_trade_instruments:
    list_of_comprehensive_SP_series.append(compute_list_of_comprehensive_SP_series(j))

内存使用率从

上升
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                   
 3672 ********  20   0 1457m 453m  26m S  0.0  0.4   0:05.23 python  

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                   
 3672 ********  20   0 1789m 785m  26m S  0.0  0.6   0:29.41 python                                                     

加在一起的所有数据框的大小确实是300 + M,通过这样做:

total_size = 0
for j in list_of_comprehensive_SP_series:
    total_size+=sys.getsizeof(j)
print total_size/1e9

输出:

0.382917456

然而,在删除数据帧列表并收回内存之后:

del list_of_comprehensive_SP_series
import gc
gc.collect()

内存使用量根本没有下降。这在我的内存密集型应用程序中非常令人沮丧。有什么帮助吗?

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                   
 3724 ********  20   0 1788m 784m  26m S  0.0  0.6   0:29.35 python                                                     

0 个答案:

没有答案