JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.55k stars 5.47k forks source link

Garbage collection of compiled code/functions? #20755

Closed robertfeldt closed 7 years ago

robertfeldt commented 7 years ago

Is there some way to garbage collect compiled functions/code?

For applications that want to compile and then temporarily use a large number of functions (for example for genetic programming, or code specialisation/synthesis applications) it might be important if there was a way the code compiled for temporary use could then be garbage collected so as not to "leak memory". Is there some way to achieve this in the current Julia implementation? If not is this something to think about for future extensions?

This is in an issue since there were not many replies in relation to a question asked on Discourse: https://discourse.julialang.org/t/is-mem-of-compiled-evaled-functions-garbage-collected/2231

nalimilan commented 7 years ago

Please use Discourse for questions, and keep GitHub for actual bug reports. Thanks!

tkelman commented 7 years ago

see https://github.com/JuliaLang/julia/issues/14495 and https://github.com/JuliaLang/julia/issues/18446 and https://github.com/JuliaLang/julia/issues/19013

if you only ever evaluate a piece of code once, you may want to write an interpreting function instead of going through the julia eval and compiler

robertfeldt commented 7 years ago

Yes, but in many cases writing the interpreter might be a much harder task than and it is not uncommon that for performance reasons one is not only executing it once but on many different test cases/inputs. But thanks for your links to related issues and discussions.