clipka <ano### [at] anonymousorg> wrote:
> If a GC implementation doesn't track free blocks, how is it ever going
> to re-allocate them to anything?
A naive implementation of that would be:
- Resolve the location of all used objects by looking for references
to those objects in the program data.
- The size of the objects can be resolved from the reference type and/or
a virtual table pointed by the objects themselves.
- Sort the addresses of the objects.
- Compact all the objects by moving them towards the beginning of the
heap so that no free space is left between them.
- Update the "free memory starts from here" pointer to the end of the
last object relocated this way.
(Of course an actual GC is much, much more complicated than that in
order to make it actually efficient.)
--
- Warp
Post a reply to this message
|