On 15 March 2016 at 17:04, Yichao Yu <[email protected]> wrote:

>
> On Mar 15, 2016 11:56 AM, "'Bill Hart' via julia-users" <
> [email protected]> 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).
>
> Haven't finish the whole email but just want to point out first that julia
> is never responsible for freeing memory you malloced, (even with jl gc
> counted malloc) the function merely make the gc aware of the memory usage
> and you always need to free it explicitly.
>
Yes, of course. We have finalizers for all C objects and the memory manager
on the C side always calls the appropriate julia free function when it
cleans up.

Note that the example I gave is just using Julia's own BigInts, nothing of
our own on the C side. It doesn't run the machine out of memory, but still
exhibits the same basic behaviour of allocating gigabytes of memory when it
should be able to collect basically everything every time Julia does a
gc_collect.

Bill.

Reply via email to