Hi All,
We are searching for a cause, why our server eventually consumes all memory and crashes, a topic discussed here Poor performance of garbage collection in multi-threaded application
We have tried to execute GC manually, but it does not seem to help. The effect we observe is very non-deterministic and we do not really know, what is going on.
As a next step, we are considering to try to reach all allocated objects in all modules and compute their size, such that we know, that there is something we have not seen
I would like to ask, if a code-snippet below make sense?
function memtracer(m::Module, depth = 0, traced = Set())
ns = filter(n -> getfield(m, n) isa Module, names(m))
ns = filter(n -> n ∉ traced, ns)
traced = union(traced, ns)
for n in ns
memtracer(getfield(m, n), depth, traced)
end
vars = filter(n -> !(getfield(m, n) isa Module), names(m))
vars = filter(n -> !(getfield(m, n) isa Function), vars)
vars = filter(n -> !(getfield(m, n) isa DataType), vars)
vars = filter(n -> !(getfield(m, n) isa Type), vars)
isempty(vars) && return()
println(repeat(" ", depth), "Module: "*string(m))
mems = map(n -> Base.summarysize(getfield(m, n)), vars)
stats = sort(collect(zip(vars, mems)), lt = (i,j) -> i[2] < j[2], rev = true)
l = maximum(length(string(v)) for v in vars) + depth
for (n,s) in stats
println(rpad(repeat(" ", depth+4)*string(n), l)," ", s)
end
nothing
end
memtracer(Main)
Or, of someone else can provide us a different strategy to achieve this, using some nice mechanism we do not know about, we would be very happy.
Thanks to all in advance,
Tomas