Board index » delphi » Garbage Collection

Garbage Collection

Does anyone have any plans on writing a garbage collector for Delphi.
My understanding is that garbage collection is competitive in speed
with standard alloc/free calls and makes dynamic object management
much easier to do.  I've used unix-based c++ garbage collectors and
they work very well.  Using a gc system really becomes {*word*60}ive.

(Delphi does seem to allow you to easily change the
memory allocation behavior of the system.)

-- Mike Salisbury

 

Re:Garbage Collection


This is a subtle point, its holes in the virtual address spave you are
talking about, not holes in real ram.  Windows virtual memory management
deals in 8K pages, and any slice of virtual memory could appear in 8K
chunks spread all over real RAM.

But to allocate a new object 100K long there needs to be 100K free in
virtual address space.  4Gigs is the current virtual address space (2Gigs
for some DPMI implementations), and I think it would be hard to fragment
up this much virtual space so badly that a contiguous chunk of any size
couldn't be found if you wanted it, without also using up so many 8K
pages (mapped all across the virtual space to fragment it) that the
processors selector table ran out of 8K pages to allocate.

You can't defragment the virtual address space because you can't track
down all the possible pointers in memory to be able to adjust them to
point to the new virtual address.

But thankfully you shouldn'd need to.

Garbage collection languages usually deal in pointers-to-pointers, you have
a fat index of all objects allocated, and what you think is a reference
to the object is really a key to this index which contains the real
pointer.  The instances of real pointers is very limited and so the real
pointers can be updated.  This effectively what happens with windows
virtual memory management only it is a function of the processor and
operating system instead of with the language.

In article <4ljsl1$...@nntp5.u.washington.edu>,

Quote
Mike Salisbury <salis...@cs.washington.edu> wrote:
>Does anyone have any plans on writing a garbage collector for Delphi.
>My understanding is that garbage collection is competitive in speed
>with standard alloc/free calls and makes dynamic object management
>much easier to do.  I've used unix-based c++ garbage collectors and
>they work very well.  Using a gc system really becomes {*word*60}ive.

>(Delphi does seem to allow you to easily change the
>memory allocation behavior of the system.)

>-- Mike Salisbury

--
--
Sam Liddicott                  |   Nothing I say is to be attributed as
Campbell Scientific Ltd.       | a company statement or representation.
14-20 Field Street, Shepshed,  *----------------------------------------

Re:Garbage Collection


In article <4ljsl1$...@nntp5.u.washington.edu>,
   salis...@cs.washington.edu (Mike Salisbury) wrote:

Quote
>Does anyone have any plans on writing a garbage collector for Delphi.
>My understanding is that garbage collection is competitive in speed
>with standard alloc/free calls and makes dynamic object management
>much easier to do.  I've used unix-based c++ garbage collectors and
>they work very well.  Using a gc system really becomes {*word*60}ive.

>(Delphi does seem to allow you to easily change the
>memory allocation behavior of the system.)

Anyone looking for a place to start on this should check out the
GetMemoryManager and SetMemoryManager functions - they let you intercept the
allocation, reallocation and disposal.

  --=- Ritchie A.

Other Threads