【发布时间】:2011-07-09 03:10:11
【问题描述】:
如何清除通过 rpy 创建的对象(以及它们占用的内存)?
import rpy2.robjects as r
a = r.r('a = matrix(NA, 2000000, 50)')
del a #if I do this, there is no change in the amount of memory used
r.r('rm(list=(ls(all=TRUE)))') # Same here, the objects disappear, but the memory is still used
不幸的是,在我的应用程序中,内存使用量会增加,直到没有足够然后它崩溃......来自rpy2 docs:
对象本身仍然可用, 并免受 R 的垃圾影响 收集直到 foo 被删除 蟒蛇
但即使这样做:
import rpy2.robjects as r
a = r.r('a = matrix(NA, 2000000, 50)')
r.r.rm('a')
del a
r.r.gc()
不释放已使用的内存...
编辑:rpy2 2.0、Win XP、R 2.12.0
【问题讨论】:
-
你怎么看内存没有被释放?
-
@eyquem: 只使用任务管理器图表和统计数据:)
标签: python memory-management rpy2