Title: Understanding the current GC, part IV
Tags: en, d, dgc, understanding the current gc, druntime, gc, mark-sweep, freeing, reallocation

What about freeing? Well, is **much** simpler than allocation_ =)

``GC.free(ptr)`` is a thread-safe wrapper for ``GC.freeNoSync(ptr)``.

``GC.freeNoSync(ptr)`` gets the ``Pool`` that ``ptr`` belongs to and clear its
bits. Then, if ``ptr`` points to a small object (bin size smaller than
``B_PAGE``), it simply link that bin to the free list (``Gcx.bucket``). If
``ptr`` is a large object, the number of pages used by the object is calculated
then all the pages marked as ``B_FREE`` (done by ``Pool.freePages(start,
n_pages)``).

Then, there is reallocation, which is a little more twisted than free, but
doesn't add much value to the analysis. It does what you think it should (maybe
except for a `possible bug`_) using functions already seen in this post or in
the `previous ones`_.

.. _allocation: http://proj.llucax.com.ar/blog/dgc/blog/post/-243ec069
.. _`possible bug`: http://www.dsource.org/projects/druntime/ticket/19
.. _`previous ones`: http://proj.llucax.com.ar/blog/dgc/blog/tag/understanding%20the%20current%20gc

.. vim: set et sw=4 sts=4 :