New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak when creating plots #726
Comments
With a patched
The sizes of the members of that Dict:
I suppose that the observable may, through the listeners, work its way back to all the plots. |
And this is exactly the reason why I was pushing for better options for disconnecting things in Makie / Observables. Because if everybody just hooks into these global observables without cleanup, references to almost everything stay in memory. I think a lot of this requires some sort of redesign to make it easier to disconnect. This JuliaGizmos/Observables.jl#48 was part of what I tried to alleviate the issue, but there was only so much you could do without breaking Observables or Makie. |
That's true, that it's part of the problem... |
In the meantime, is there a recommended workaround? I will do this unless someone has a better suggestion: for k in keys(AbstractPlotting._current_default_theme)
try
empty!(AbstractPlotting._current_default_theme[k].listeners)
catch ex
if !isa(ex, KeyError)
throw(ex)
end
end
end |
@SimonDanisch Thanks for your work on this issue so far. It looks like this isn't fixed yet, though. Using AbstractPlotting v0.13.10 and GLMakie v0.1.16, this code: using AbstractPlotting, GLMakie
function do_leak()
plot = scatter(1:200000000)
GLMakie.destroy!.(plot.current_screens)
plot = nothing
AbstractPlotting.current_global_scene[] = nothing
GC.gc(true)
@info "Size of AbstractPlotting: $(Base.format_bytes(Base.summarysize(AbstractPlotting)))"
end
for i in 1:10
@info "Iteration $i"
do_leak()
println()
end outputs this:
Let me know if you want me to test anything else. |
Describe the bug
When creating a plot (e.g.,
scatter(1:20000)
), the memory used for that plot is retained indefinitely and never reclaimed by the GC.Steps To Reproduce
These two examples both retain around 15GB of memory forever:
Example 1
Example 2
Expected behavior
After I create a plot and discard all references to it that I know of (i.e., the
plot
reference itself andAbstractPlotting.current_global_scene
), I expect the memory used for that plot to be freed.Additional Information
This looks similar to #382
This has been reproduced by @ianshmean
This is the output from
varinfo
: https://pastebin.com/qAy0ZvtjHere is a more descriptive example and the outputs it produces:
The text was updated successfully, but these errors were encountered: