Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Garbage collection mystery #9415
Synopsis: Garbage collection is taking significant time, even when (I think) nothing is destroyed.
After loading the following code...
type Container data::Float64 end function funC(n::Int) tic() C = Array(Container,n) for i = 1:n C[i] = Container(0.0) end println(" C's length: $(length(C))") println(" inside time: $(toq())") end function testC(n::Int = 100000000, manualGC::Bool = false) tic() funC(n) println("outside time: $(toq())") if manualGC tic() gc() println(" manual gc(): $(toq()) (only time for this gc() call)") end println("----------------------") end
... and then running once to compile (not shown). I then run as follows:
There is a relatively large amount of time spent garbage collecting (approx 50%) . The first test shows that the bulk of the garbage collection happens neither upon the exit of
My apologizes if I am missing something, but it seems to me that nothing should be destroyed until after
I am using Julia 0.4.0-dev+2006 (2014-12-08 21:48 UTC)
Thanks for any feedback.
Point taken about the approperiate venue for this type of question, sorry about that, and thank for the quick answer :)
To expand a bit, the gc doesn't spend much time actually "destroying" things (arguably it is the fastest part of the work). Most of the time is spent walking the heap to see if anything needs to be destroyed.