In 0.3.5.

julia> @time sum(rand(100000000))
ERROR: MemoryError()
 in rand at random.jl:123

julia> gc()

julia> @time sum(rand(100000000))
elapsed time: 4.127246913 seconds (800000168 bytes allocated, 0.83% gc time)
4.999858681707974e7

julia> gc()

julia> @time sum(rand(1000000000)) # ten time more, that I understandably 
can't get around unless I close other programs
ERROR: MemoryError()
 in rand at random.jl:123

julia> @time sum(rand(100000000))
elapsed time: 3.418166239 seconds (800000168 bytes allocated, 1.56% gc time)
5.000421281918045e7


$ ps aux |grep julia
palli    19981  4.5 21.4 1095364 866536 pts/4  S+   16:57   0:15 julia

$ ps aux |grep julia
palli    19981  1.6 20.2 1160900 817812 pts/4  S+   16:57   0:19 julia


Main question:

I know often there isn't much to to if memory has really run out (yes, you 
could catch the exception and do something - what? in say safety critical 
situations). Going by the next try after the gc() it seems the memory had 
not actually run out. I thought if memory is low because of garbage, then 
first a gc() would be forced and only if there really is not enough memory 
then you get the error.

[I guess there is a tiny possibility that the memory available to Julia got 
bigger inbetween.]

I'm looking into this, I guess the above depends on memory being allocated 
in one chunk, maybe not something to be relied on?


[I expect the memory available to julia process (VSZ, not RSS) to just grow 
and never shrink right?]

[The last @time gets less time while there is more gc work.. Probably a 
coincidence/load from other processes explain, otherwise would be odd?]


-- 
Palli.

P.S.

This works:

julia> edit(rand, (Real,))

but strangely not:

julia> edit(rand, (Float64,))
ERROR: could not find function definition
 in functionlocs at reflection.jl:171
 in edit at interactiveutil.jl:56

Reply via email to