-
Notifications
You must be signed in to change notification settings - Fork 58
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 #76
Comments
Cc: @tanmaykm @amitmurthy |
close(t::Timer) also works for SingleAsyncWork, so let that method take both. Further, the close hook for SingleAsyncWork needs to remove it from the preservation dict.
Seems to be fixed. Thank you, @Keno! |
Was this a problem with both 0.3 and 0.4? |
Yes. |
And after 791b5d4 in the package, 0.3 still leaks memory? |
@StefanKarpinski knows the details best about what had to be done on 0.3. Let's wait for him to chime in. |
I'm going to sleep. @staticfloat may be online for a little while, and can do anything necessary with binaries. If we decide to immediately backport the corresponding Julia commit and re-tag, I'd personally be in favor of leaving the 0.3.7 tag in place since who knows how many people have fetched it by now, and just go straight to 0.3.8. |
Yes, it can certainly wait a week or two for 0.3.8. |
I should have fixed this on both 0.3 and 0.4. |
So this original example still memory leaks – just much more slowly than before. Looking into the cause. |
Cc @tanmaykm, since you are also a heavy user of this package... |
This seems to be a bug upstream |
Can see the leak even with just open and close of sockets. test code: https://gist.github.com/tanmaykm/8352059108c6b34f5ecf |
I see that leaks are present even after closing the context after calling This does not fix the bug. |
The original script to reproduce this leaks for a different reason – the calls to
|
Similar leakage on OS X:
|
The only operation in the loop in this script is |
I suspect it's due to the finalizer. |
Ah, good thought, @yuyichao! |
I'm trying to rebase and fix JuliaLang/julia#13995 now ... |
Hmm, it seems that you are plotting the virtual address space size? It's not the most useful measure since you are mostly measuring the 8G gc memory pool. This also kind of means that the leak is not in the GC pool objects..... |
That's a fair point and I'm happy to measure something else, but this does reflect the impact of the program from the system's perspective – and it keeps using more and more resources while doing a very trivial loop. |
I agree, I just mean that the reason of the leak is a little strange since it's apparently not JuliaLang/julia#13993 and isn't really fixed by JuliaLang/julia#13995 |
The leak maybe in libuv like JuliaLang/julia#13529 probably is due to a libuv issue. |
Has anybody run |
Hey all. So looking into things, people don't advise finalizers. They advise using https://docs.julialang.org/en/latest/manual/functions/#Do-Block-Syntax-for-Function-Arguments-1. This is recommended by Tim Holy: JuliaLang/julia#11207 (comment) I'm thinking that we should not rely on finalizers. The issue is that lifetimes aren't strictly managed by scopes in Julia, things are garbage-collected. If lifetimes aren't managed by scopes, then finalizers could run whenever the gc is tuned to, after the scope closes. That's just how resource management is done in Julia. So while memory management could be handled by Julia's gc, sockets, contexts, and messages shouldn't be, because they could hang around until gc deigns to release them and this would result in resource leaks, specifically open threads and memory. This requires a bit of a redesign, obviously. I can do it (actually I already did it in my own clone of ZMQ.jl). Would people be interested in this? The nice bit is that it really only involves removing a lot of code from ZMQ.jl, simplifying interfaces. It also makes the Julia bindings more in line with both ZMQ and Julia paradigms. I am thinking we can remove the Julia bindings that relate to ZMQ contexts entirely. AFAICT there really is only one use case for having more than one ZMQ context: ZMQ being imported in multiple places. That can be accomplished by a global variable holding the context handle. Julia takes care of each import having its own global, and then we can hide contexts from the user nearly altogether. (If users really want to control contexts, we can make some package-level functions for that.) Thoughts? |
For the record, I cannot reproduce this on Julia 1.11 and latest master of ZMQ.jl using an updated version of Stefans scripts: https://gist.github.com/JamesWrigley/e85eba789719c818912067f5aa43ec57 On my machine: julia> data = readdlm("vsz.csv", ',', Float64, '\n');
julia> using UnicodePlots
julia> lineplot(data[:, 2], data[:, 3] / 1e6; width=60, xlabel="Step number", ylabel="Memory usage [MB]", title="Memory usage vs time") (pasting an image because Github doesn't format the plot nicely) I think we can close this, if no one else can reproduce it. |
Example code:
The virtual size keeps growing endlessly.
The text was updated successfully, but these errors were encountered: