Understanding the current GC, part IV
by Leandro Lucarella on 2009- 04- 10 21:33 (updated on 2009- 04- 10 21:33)- with 0 comment(s)
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.