Skip to content
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

try to unreference objects sooner in generated code #8393

Closed
DumpsterDoofus opened this issue Sep 17, 2014 · 3 comments
Closed

try to unreference objects sooner in generated code #8393

DumpsterDoofus opened this issue Sep 17, 2014 · 3 comments
Labels
compiler:codegen Generation of LLVM IR and native code performance Must go faster

Comments

@DumpsterDoofus
Copy link

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.

@IainNZ
Copy link
Member

IainNZ commented Sep 17, 2014

Note it doesn't seem to only be at the REPL:

function OscarTheGrouch()
    A = rand(Float32, 20000, 20000);
    A = 0;
    gc();
end
OscarTheGrouch()
readline()

@JeffBezanson
Copy link
Member

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 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
@JeffBezanson JeffBezanson added the performance Must go faster label Sep 17, 2014
@JeffBezanson JeffBezanson added the compiler:codegen Generation of LLVM IR and native code label Apr 7, 2017
@vtjnash
Copy link
Member

vtjnash commented Sep 12, 2017

#21888 : The GC root placement pass 1.0 deserves

@vtjnash vtjnash closed this as completed Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:codegen Generation of LLVM IR and native code performance Must go faster
Projects
None yet
Development

No branches or pull requests

4 participants