On Tuesday, 15 March 2016 19:02:41 UTC+1, Yichao Yu wrote:
>
> On Tue, Mar 15, 2016 at 1:45 PM, Yichao Yu <[email protected] <javascript:>> 
> wrote: 
> > 
> > On Mar 15, 2016 11:56 AM, "'Bill Hart' via julia-users" 
> > <[email protected] <javascript:>> wrote: 
> >> 
> >> We have been trying to understand the garbage collector behaviour, 
> since 
> >> we had some code for which our machine is running out of memory in a 
> matter 
> >> of an hour. 
> >> 
> >> We already realised that Julia isn't responsible for memory we allocate 
> on 
> >> the C side unless we use jl_gc_counted_malloc, which we now do 
> everywhere. 
> >> But it still uses masses of memory where we were roughly expecting no 
> growth 
> >> in memory usage (lots of short-lived objects and nothing much else). 
> >> 
> >> The behaviour of the gc on my machine seems to be to allocate objects 
> >> until 23mb of memory is allocated, then do a jl_gc_collect. However, 
> even 
> >> after reading as much of the GC code in C as I can, I still can't 
> determine 
> >> why we are observing the behaviour we are seeing. 
> >> 
> >> Here is a concrete example whose behaviour I don't understand: 
> >> 
> >>      function doit2(n::Int) 
> >>          s = 
> >> BigInt(2234567876543456789876545678987654567898765456789876545678) 
> >>          for i = 1:n 
> >>             s += i 
> >>          end 
> >>          return s 
> >>       end 
> >> 
> >>      doit(10000000000) 
>
> Another note is that adding finalizers will (currently) extend the 
> lifetime of an object. https://github.com/JuliaLang/julia/pull/13995 
> should solve this problem but I'm holding on to it before we finish 
> some other GC rework. 
>

This at least sounds like it might be related to the problem we are seeing.

I guess it means an object with a finalizer cannot be immediately cleaned 
up if it is short lived. The only way for such an object to get cleaned up 
is in long lived territory, which the state diagram seems to suggest is the 
only place a finalizer can even be scheduled. Is that about correct (I have 
to explain it to someone else, so I'm hoping to not tell them too many 
wrong things).

Bill. 

Reply via email to