-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Generated code memory leaks #14495
Comments
Thanks for filing - so that this can be tracked. |
Is this just because we don't free jit code? |
We don't free the results of |
Is it possible to solve this? |
Reopened. I think this is a real issue that I'd like to fix eventually. |
This is great news :) For us this is a real stopper. Thanks Jeff. |
Is it generated code that is causing the maxrss to monotonically increase with every set of tests in the entire suite? If so, this issue affects my ability to run all the tests on my laptop which has 4GB. Right now, I can only run the tests single-threaded ( |
Yes, that's probably a significant part of the problem. Also ref #14626 |
We could also perhaps restart workers more frequently, e.g. every few test files, to use less persistent memory. |
There's an environment variable you can set to do just that. Have to look at runtests to check exactly how it's spelled. |
We already have |
There are also use cases from genetic programming and other code generation/synthesis situations when one wants to compile and run a large number of programs in order to then select some subset of them. See discussion here: Also see the (closed) issue here: |
Status of this? |
My issue #37560 was closed. So I am posting my MWE here. I used Flux/Zygote with pmap.
|
In another use case, I have been having the same problem with a combination of Distributed and RCall.jl. It appears that repeated uses of RCall are causing a similar memory leak in my case up to 1TB of combined RAM and VRAM usage. |
Just closed my fresh issue as a duplicate of this one. Repeatedly creating closures.
Here my minimal reproducible example for _ in 1:50
@eval function myfunc() end
GC.gc(true); GC.gc(false)
Core.println(Base.gc_live_bytes() / 2^20)
end |
GC for code is going to be rather challenging. Besides the mechanics of being able to free the memory one must be able to prove that the code has become unreachable. While Julia's world-age mechanism might be able to be reused for that, we also have an intrinsic |
Okay, I see, that is why even the function with the same name cannot "overwrite" itself, because of different world ages... Is there a manual way to completely cleanup such functions? (let's assume we know their name) |
Not currently, it would require re-engineering parts of the JIT compiler to separate functions into individual The only current way is to restart your Julia session ;) |
Hi,
|
I don't believe JITed functions can be freed (aside from exiting the process). |
Yes, I had similar goals but at least concluded back then (a few years ago) that generated functions are not GC'ed so cannot use for genetic programming type of algorithms easily. |
It should be possible to eventually GC native code, but doing so is hard, and the use-case is limited. For genetic programming it might be better to use https://github.com/JuliaDebug/JuliaInterpreter.jl |
It might also be easy to write a custom "interpreter" if the functions have a limited enough set of behaviors. E.g., a vector for storing temporaries, and a while loop with |
Thanks for all the tips, guys! I really appreciate it. I will consider which one is the most suitable for my application and try it out. |
Hello guys!
I found a generated code related memory leak issue. I wrote a post about it on julia-lang users group, but it looks like everyone have no time for that. I emailed to @JeffBezanson about this issue and he knows about it. I have no possibility to fix this by myself, because i have no such experience in C. So, i decided to create this issue to track it somehow.
So, here is a problem:
Every call of
leak()
eats ~30mb of memory on my PC. This problem exists on both Linux and Windows platforms.The text was updated successfully, but these errors were encountered: