1

为什么在这种简单的情况下垃圾收集器无法释放 JuMP 分配的所有内存?@time 也只返回 71M。

using JuMP, GLPKMathProgInterface
function memuse()
  pid = parse(Int,readall(pipeline(`ps axc`,`awk "{if (\$5==\"julia\") print \$1}"`) ))
  return string(round(Int,parse(Int,readall(`ps -p $pid -o rss=`))/1024),"M")
end

function optimize()
  m = Model(solver=GLPKSolverLP())
  @variable(m, x[1:10] >= 0)
  @constraint(m, con[i = 1:10000000], x⋅rand(10) >=0)
  solve(m)
  return getobjectivevalue(m)
end

println("Before $(memuse())")
@time optimize()
println("Created $(memuse())")
gc()
println("After gc() $(memuse())")

输出

Before 139M
 11.683382 seconds (71.59 M allocations: 3.635 GB, 44.04% gc time)
Created 1471M
After gc() 924M

groups.google.com/forum/#!topic/julia-opt/zZr5dnQIJno

4

0 回答 0