среда, 16 декабря 2015 г., 17:02:11 UTC+2 пользователь DeadbraiN написал:
>
> Hi everybody,
>
> It looks like i found memory leak in a Task related code and fatal error. 
> First, please look at this example:
> function leak()
> for i=1:10000
> f = eval(:(function() produce() end))
> t = @async f()
> consume(t)
>                 # stop the Task
> t.exception = null
> try
>  yieldto(t)
> end
> end
> gc()
> end
> Every time i run leak() function, memory usage of juia process increases 
> on ~35mb on my machine.
>
> Second issue (with fatal error) is with the same code, but one simple 
> change:
> function leak()
> for i=1:10000
> f = eval(:(function() produce() end))
> t = @async f()
> #consume(t)  # this is a change
>                 # stop the Task
> t.exception = null
> try
>   yieldto(t)
> end
> end
> gc()
> end
> This change produces an error like this:
>
> fatal: error thrown and no exception handler available.
> null
> rec_backtrace at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> jl_throw at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown 
> line)
> unknown function (ip: 0x7fc9e946f372)
> yieldto at ./task.jl:71
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> wait at ./task.jl:371
> task_done_hook at task.jl:174
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> unknown function (ip: 0x7fc9e946eb4a)
> unknown function (ip: (nil))
>
> And finally, it works fine (without memory leaks) with this small change:
>
> function leak()
> for i=1:100000 # added one zero symbol at the end
> f = function() produce() end # removed eval()
> t = @async f()
> consume(t)
>                 # stop the Task
> t.exception = null
> try
>  yieldto(t)
> end
> end
> gc()
> end
>
> So, my question is: what i should change to prevent memory leaks?
> Thanks
>
> julia> versioninfo()
> Julia Version 0.4.2
> Commit bb73f34 (2015-12-06 21:47 UTC)
> Platform Info:
>   System: Linux (x86_64-linux-gnu)
>   CPU: Intel(R) Core(TM) i7-4700HQ CPU @ 2.40GHz
>   WORD_SIZE: 64
>   BLAS: libopenblas (NO_LAPACK NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Haswell)
>   LAPACK: liblapack.so.3
>   LIBM: libopenlibm
>   LLVM: libLLVM-3.3
>
>
> This is optimized variant of memory leak example:
>
function leak()
for i=1:100000
t = Task(eval(:(function() produce() end)))
consume(t)

try
 t.exception = null
 yieldto(t)
end
end
gc()
end

 

Reply via email to