Re: Best Ref-counting algorithms?

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Wed, 15 Jul 2009 03:13:33 +0200

          From comp.compilers

Related articles
[3 earlier articles]
Re: Best Ref-counting algorithms? cr88192@hotmail.com (BGB / cr88192) (2009-07-13)
Re: Best Ref-counting algorithms? torbenm@pc-003.diku.dk (2009-07-14)
Re: Best Ref-counting algorithms? lerno@dragonascendant.com (=?ISO-8859-1?Q?Christoffer_Lern=F6?=) (2009-07-14)
Re: Best Ref-counting algorithms? haberg_20080406@math.su.se (Hans Aberg) (2009-07-14)
Re: Best Ref-counting algorithms? georgeps@xmission.com (GPS) (2009-07-14)
Re: Best Ref-counting algorithms? gneuner2@comcast.net (George Neuner) (2009-07-14)
Re: Best Ref-counting algorithms? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-07-15)
Re: Best Ref-counting algorithms? lerno@dragonascendant.com (=?ISO-8859-1?Q?Christoffer_Lern=F6?=) (2009-07-14)
Re: Best Ref-counting algorithms? lerno@dragonascendant.com (=?ISO-8859-1?Q?Christoffer_Lern=F6?=) (2009-07-15)
Re: Best Ref-counting algorithms? torbenm@pc-003.diku.dk (2009-07-15)
Re: Best Ref-counting algorithms? cr88192@hotmail.com (BGB / cr88192) (2009-07-15)
Re: Best Ref-counting algorithms? cr88192@hotmail.com (BGB / cr88192) (2009-07-15)
Re: Best Ref-counting algorithms? cr88192@hotmail.com (BGB / cr88192) (2009-07-15)
[24 later articles]
| List of all articles for this month |
From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: Wed, 15 Jul 2009 03:13:33 +0200
Organization: Compilers Central
References: 09-07-018 09-07-032 09-07-038
Keywords: GC
Posted-Date: 15 Jul 2009 19:22:47 EDT

GPS schrieb:


> If a GC results in page transfers to/from the disk, then it will drastically
> slow down the program, and system.


Good point!




> Reference counting usually requires more work from the programmer. In my
> own work, I have found a shadow of doubt forms about all of my usage of
> reference counting, and thus I do not feel confident about code, until it
> has been tested, and even then, I have doubts.


Since years I'm happy with the Delphi RC model, including copy-on-write.
There may exist very rare cases for manual intervention, though.




> Reference counting can require more memory than other types of GC, because a
> container is usually used that contains a refcount, and a union of some
> primitive storage for type(s). This means that accessing data requires more
> indirection, and allocation of the container is required.


I see no need for additional containers. Collectable elements already
are heap objects, with management information about allocated size and
links to other heap elements. The RC'ed elements can hold all additional
information in an extended version of that heap management structure,
possibly hidden from the user.


IMO the only required overhead are layout descriptors for all data
structures (including subroutine stack layout), which contain references
to ref-counted elements. Not really different from other GC models.


> One alternative
> for some situations is to pass register-sized quantities directly, and rely
> on a container or object structure for more complex types.


Can you give a practical example? When such "objects" are passed along
*by value*, I see no need for counting references in such context.




> With a mark-and-sweep GC you can use a tag bit, with some extra indirection,
> and thus may avoid the need for a container.


As mentioned above, how would such a GC handle gaps resulting from freed
memory blocks, and how would it determine the type (layout) of all the
heap elements?


IMO such overhead is independent from a specific GC model. In real life
it won't make a remarkable difference in the memory footprint, whether a
GC model adds a single mark bit to every heap element, or a whole count
word.


DoDi



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.