为什么在这个简单的情况下,垃圾收集器无法释放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