You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I originally posted this on StackOverflow, but calling gc() inside of a function does not always appear to work properly. Iain was able to reproduce the issue, and suggested I post it here.
I originally encountered this issue (bug?) when I was running code that I had been pasting into the REPL from a text editor, and decided to instead put the code inside a function in order to make it more convenient to execute. I was surprised to find that the exact same code which executed in the global scope without any problems would swallow up all the available RAM on my computer and give a MemoryError when it was wrapped in a function and called. From there, I was able to isolate the issue, giving the minimal example shown in the link above.
The text was updated successfully, but these errors were encountered:
Yes this has to do with how code is generated. The rand call comes down to rand!(Array(T, dims)), and the inner Array remains on the "argument stack", since those slots generally get reused. It would be good to null out those slots in a case like this, but it has to be done very carefully to avoid adding lots of unnecessary stores.
JeffBezanson
changed the title
Garbage collection appears to operate differently inside and outside of functions
try to unreference objects sooner in generated code
Sep 17, 2014
I originally posted this on StackOverflow, but calling
gc()
inside of a function does not always appear to work properly. Iain was able to reproduce the issue, and suggested I post it here.I originally encountered this issue (bug?) when I was running code that I had been pasting into the REPL from a text editor, and decided to instead put the code inside a function in order to make it more convenient to execute. I was surprised to find that the exact same code which executed in the global scope without any problems would swallow up all the available RAM on my computer and give a
MemoryError
when it was wrapped in a function and called. From there, I was able to isolate the issue, giving the minimal example shown in the link above.The text was updated successfully, but these errors were encountered: