I just did an experiment with:

function doforever()
   while true
       produce(zeros(100000,10000)) # ~8 gigabytes
   end
end

and the memory deallocated when I did an explicit gc().


On Tuesday, December 8, 2015 at 7:19:42 AM UTC-8, James Fairbanks wrote:
>
> I noticed a typo in my original post function g should have been:
>
> function g(n::Int)
>      t = @task doforever()
>      for i in 1:n
>            println(consume(t))
>      end
> end
>
> On Tuesday, December 8, 2015 at 9:34:18 AM UTC-5, James Fairbanks wrote:
>>
>> Task objects, which are created by @task f(args), hold on to some 
>> resources. How do those resources get released? 
>>
>> For example, if I have a function that makes a task that doesn't return, 
>> what happens?
>>
>> function doforever()
>>      while true
>>           produce(true)
>>      end
>> end
>>
>> function g(n::Int)
>>      t = @task doforever()
>>      for i in 1:n
>>            return consume(t)
>>      end
>> end
>>
>> for i in 1:10000
>>     g(5)
>> end
>>
>> How many tasks are still in existence at the end of this loop?
>> Do the resources associated with a task get released as soon as all 
>> references to the Task instance go out of scope?
>> Does the task need to be "done" before releasing the resources?
>>
>> I expect the answers to be 1 (the main task), yes (at first available gc 
>> cycle), no.
>> The docs page http://docs.julialang.org/en/release-0.4/stdlib/parallel/ 
>> doesn't really cover these issues so I am not sure.
>> Also is there a reference that details what resources Task instances 
>> possess? 
>>
>

Reply via email to