1 Title: Understanding the current GC, part IV
2 Tags: en, d, dgc, understanding the current gc, druntime, gc, mark-sweep, freeing, reallocation
4 What about freeing? Well, is **much** simpler than allocation_ =)
6 ``GC.free(ptr)`` is a thread-safe wrapper for ``GC.freeNoSync(ptr)``.
8 ``GC.freeNoSync(ptr)`` gets the ``Pool`` that ``ptr`` belongs to and clear its
9 bits. Then, if ``ptr`` points to a small object (bin size smaller than
10 ``B_PAGE``), it simply link that bin to the free list (``Gcx.bucket``). If
11 ``ptr`` is a large object, the number of pages used by the object is calculated
12 then all the pages marked as ``B_FREE`` (done by ``Pool.freePages(start,
15 Then, there is reallocation, which is a little more twisted than free, but
16 doesn't add much value to the analysis. It does what you think it should (maybe
17 except for a `possible bug`_) using functions already seen in this post or in
20 .. _allocation: http://proj.llucax.com.ar/blog/dgc/blog/post/-243ec069
21 .. _`possible bug`: http://www.dsource.org/projects/druntime/ticket/19
22 .. _`previous ones`: http://proj.llucax.com.ar/blog/dgc/blog/tag/understanding%20the%20current%20gc
24 .. vim: set et sw=4 sts=4 :