GraphViz.jl icon indicating copy to clipboard operation
GraphViz.jl copied to clipboard

Memory leak?

Open ffevotte opened this issue 1 year ago • 0 comments

Hi,

when running a simple script like this:

using GraphViz
using FileIO

function foo()
    g = dot"""
      digraph graphname {
        a -> b -> c;
        b -> d;
      }
    """
    FileIO.save("graph.svg", g)

    GraphViz.free(g)  # This should be called as a finalizer, but let's be explicit
    nothing
end

for i in 1:1000
    i % 10 == 0 && println(i)
    foo()
    GC.gc()
end

# It's convenient to wait in the end; this makes it easy to check the final
# memory consumption with something like `top`
println("Done. Press ^C to abort")
sleep(3600)

one can readily see with a tool like top that the memory consumption of the Julia process slowly but surely increases. On my system, resident memory is around 275Mb for the first few iterations, and increases to around 305Mb after the 1000th.

Explicitly calling free does not seem to change anything, so it would look like the issue is more subtle than a finalizer not being called.

Is that an issue with my code? Or is there a memory leak somewhere? (And in the latter case, do you think it is an upstream issue or an issue with GraphViz.jl?)

Thanks in advance!

ffevotte avatar Feb 17 '24 18:02 ffevotte