[Vm-dev] What is a free object

John M McIntosh johnmci at smalltalkconsulting.com
Thu Jul 26 19:31:35 UTC 2007


On Jul 26, 2007, at 10:43 AM, Bert Freudenberg wrote:
>> since Squeak (fortunately) has a garbage collector, the heap does not
>> just consist of actual objects, but also of chunks of unused memory.
>> However, these also have an object header to be more easily handled:
>> during allocation, the memory manager must be able to find a free
>> piece of heap memory to assign it to the newly allocated object.  
>> These
>> chunks of free memory are what the VM code calls "free objects".


To clarify this, the memory allocation logic does not scan for these  
free spaces when allocating new objects.
Rather it allocates memory from the end of the image which is the  
free space after the last GC, by using a simple math on the freeblock  
pointer.

A simplistic view:

After N allocations or if we can't allocate the memory a incremental  
GC is done which garbage collects  young space
and makes the free blocks as it find objects that are garbage. After  
the mark sweep phase of the GC, it runs compact phase
which then moves objects down to perculate all that free space up,  
then resets the freeblock pointer. At this point young space is
fully compacted.   If a full GC runs, then all of object memory is  
GCed and compacted leaving no free blocks in memory.



--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===




More information about the Vm-dev mailing list