Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > C++0x Garbage Collection

Reply
Thread Tools

C++0x Garbage Collection

 
 
Goalie_Ca
Guest
Posts: n/a
 
      06-24-2006
I have been reading (or at least googling) about the potential addition
of optional garbage collection to C++0x. There are numerous myths and
whatnot with very little detailed information.

Will this work be library based or language based and will it be based
on that of managed C++? Then of course there are the finer technical
questions raised (especially due to pointer abuse). Is a GC for C++
just a pipe dream or is there a lot of work in the committee to realise
it.

 
Reply With Quote
 
 
 
 
Roland Pibinger
Guest
Posts: n/a
 
      06-24-2006
On 23 Jun 2006 23:49:30 -0700, "Goalie_Ca" <(E-Mail Removed)> wrote:
>I have been reading (or at least googling) about the potential addition
>of optional garbage collection to C++0x. There are numerous myths and
>whatnot with very little detailed information.


C++ needs no garbage collection because it offers something better:
deterministic resource management with destructors. You should have
googled for 'RAII' instead of 'garbage collection'. Actually, RAII is
the 'unique selling proposition' of C++. Introducing GC into C++ would
only make it a worse Java or C#.

Best wishes,
Roland Pibinger
 
Reply With Quote
 
 
 
 
Mirek Fidler
Guest
Posts: n/a
 
      06-24-2006
Roland Pibinger wrote:
> On 23 Jun 2006 23:49:30 -0700, "Goalie_Ca" <(E-Mail Removed)> wrote:
>
>>I have been reading (or at least googling) about the potential addition
>>of optional garbage collection to C++0x. There are numerous myths and
>>whatnot with very little detailed information.

>
>
> C++ needs no garbage collection because it offers something better:
> deterministic resource management with destructors. You should have
> googled for 'RAII' instead of 'garbage collection'.


Alternatively, go directly here:

http://upp.sf.net

and take a look at sources

You can e.g. start here:

http://upp.sourceforge.net/www$uppweb$vsswing$en-us.html

RAII rules GC.

Mirek
 
Reply With Quote
 
Roland Pibinger
Guest
Posts: n/a
 
      06-24-2006
On Sat, 24 Jun 2006 09:58:51 +0200, Mirek Fidler <(E-Mail Removed)> wrote:

>Roland Pibinger wrote:
>> On 23 Jun 2006 23:49:30 -0700, "Goalie_Ca" <(E-Mail Removed)> wrote:
>>
>>>I have been reading (or at least googling) about the potential addition
>>>of optional garbage collection to C++0x. There are numerous myths and
>>>whatnot with very little detailed information.

>>
>> C++ needs no garbage collection because it offers something better:
>> deterministic resource management with destructors. You should have
>> googled for 'RAII' instead of 'garbage collection'.

>
>Alternatively, go directly here:
>
>http://upp.sf.net
>and take a look at sources
>You can e.g. start here:
>http://upp.sourceforge.net/www$uppweb$vsswing$en-us.html


Definitely worth a look and a trial although, for my taste, too "smart
and aggressive" in the use of C++.

>RAII rules GC.




Best wishes,
Roland Pibinger
 
Reply With Quote
 
Joe Seigh
Guest
Posts: n/a
 
      06-24-2006
Goalie_Ca wrote:
> I have been reading (or at least googling) about the potential addition
> of optional garbage collection to C++0x. There are numerous myths and
> whatnot with very little detailed information.
>
> Will this work be library based or language based and will it be based
> on that of managed C++? Then of course there are the finer technical
> questions raised (especially due to pointer abuse). Is a GC for C++
> just a pipe dream or is there a lot of work in the committee to realise
> it.
>


Part of the problem is there are different forms of GC. Even for tracing
GC there are enough differences that being able to plug in at the library
level might be a little problematic. Whatever solution they pick is not
likely to be neutral as far as the alternative solutions are concerned.

--
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software.
 
Reply With Quote
 
Jerry Coffin
Guest
Posts: n/a
 
      06-24-2006
In article <(E-Mail Removed). com>,
http://www.velocityreviews.com/forums/(E-Mail Removed) says...
> I have been reading (or at least googling) about the potential addition
> of optional garbage collection to C++0x. There are numerous myths and
> whatnot with very little detailed information.
>
> Will this work be library based or language based and will it be based
> on that of managed C++? Then of course there are the finer technical
> questions raised (especially due to pointer abuse). Is a GC for C++
> just a pipe dream or is there a lot of work in the committee to realise
> it.


There were a couple of lengthy threads about this in
comp.lang.c++.moderated. See:

http://tinyurl.com/s57fq

and:

http://tinyurl.com/p5op2

For starters. When I said lengthy, I wasn't kidding though -- reading
through all this will take considerable time (and this thread will
probably echo many of the same arguments).

--
Later,
Jerry.

The universe is a figment of its own imagination.
 
Reply With Quote
 
Goalie_Ca
Guest
Posts: n/a
 
      06-25-2006
Thanks for those threads. I can see that in general people are divided
at every level on how to approach this problem. To me, the outsider, it
appears that it will not likely make this revision although there is
clearly support for having one included.


Jerry Coffin wrote:
> In article <(E-Mail Removed). com>,
> (E-Mail Removed) says...
> > I have been reading (or at least googling) about the potential addition
> > of optional garbage collection to C++0x. There are numerous myths and
> > whatnot with very little detailed information.
> >
> > Will this work be library based or language based and will it be based
> > on that of managed C++? Then of course there are the finer technical
> > questions raised (especially due to pointer abuse). Is a GC for C++
> > just a pipe dream or is there a lot of work in the committee to realise
> > it.

>
> There were a couple of lengthy threads about this in
> comp.lang.c++.moderated. See:
>
> http://tinyurl.com/s57fq
>
> and:
>
> http://tinyurl.com/p5op2
>
> For starters. When I said lengthy, I wasn't kidding though -- reading
> through all this will take considerable time (and this thread will
> probably echo many of the same arguments).
>
> --
> Later,
> Jerry.
>
> The universe is a figment of its own imagination.


 
Reply With Quote
 
Ron House
Guest
Posts: n/a
 
      06-26-2006
Goalie_Ca wrote:
> Thanks for those threads. I can see that in general people are divided
> at every level on how to approach this problem. To me, the outsider, it
> appears that it will not likely make this revision although there is
> clearly support for having one included.


My question is a simple one: how do we combine destructors with GC?
Destructors do not become superfluous just because one usage for them
does. Closing files and shutting down other resources in a timely manner
becomes hard when object termination occurs at an indeterminate time. Is
there a way to do this that is sufficiently practical and efficient to
raise no major objections if put into a standard? It is one thing for an
add-on to do it, as we use or not use the add-on to our own liking; but
a standard is another matter.

--
Ron House (E-Mail Removed)
http://www.sci.usq.edu.au/staff/house
 
Reply With Quote
 
Jerry Coffin
Guest
Posts: n/a
 
      06-26-2006
In article <(E-Mail Removed)>, (E-Mail Removed) says...
> Goalie_Ca wrote:
> > Thanks for those threads. I can see that in general people are divided
> > at every level on how to approach this problem. To me, the outsider, it
> > appears that it will not likely make this revision although there is
> > clearly support for having one included.

>
> My question is a simple one: how do we combine destructors with GC?


One of the threads I previously cited was titled "Reconciling Garbage
Collection with Deterministic Finalization". Even with little or no
knowledge of the subject matter, the mere fact that the thread went
on for well over 300 posts tends to show that nobody has a really
solid answer for that.

--
Later,
Jerry.

The universe is a figment of its own imagination.
 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      06-26-2006
* Ron House:
> Goalie_Ca wrote:
>> Thanks for those threads. I can see that in general people are divided
>> at every level on how to approach this problem. To me, the outsider, it
>> appears that it will not likely make this revision although there is
>> clearly support for having one included.

>
> My question is a simple one: how do we combine destructors with GC?
> Destructors do not become superfluous just because one usage for them
> does. Closing files and shutting down other resources in a timely manner
> becomes hard when object termination occurs at an indeterminate time. Is
> there a way to do this that is sufficiently practical and efficient to
> raise no major objections if put into a standard? It is one thing for an
> add-on to do it, as we use or not use the add-on to our own liking; but
> a standard is another matter.


It's very simple: object destruction is not memory reclamation, and
memory reclamation is not object destruction.

The job of a garbage collector is solely to reclaim memory.

If an object has a non-trivial destructor, one with possible side
effects, then that object cannot be automatically destroyed by a garbage
collector in order to reclaim memory, because then the garbage collector
would intrude in the arena of program logic and correctness.

Thus, a C++ garbage collector compatible with the current standard can
reclaim a region of memory only when:

A. There are no live references to the region (circular references
are not live), and

B. All remaining objects in the region have trivial destructors.

The case where there are no remaining objects in the region (i.e. all
have been destroyed) might seem to be of no practical advantage, but it
is if :perator delete, rather than deallocating at once, just invokes
object destruction and marks the memory for later automatic reclamation,
which can proceed e.g. when the program's later waiting for user input.

This reduces garbage collection in C++ to an /optimization/ and /memory
leak slurper/, not affecting correctness except to the degree it slurps.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
Templates - Garbage In Garbage Not Out ramiro_b@yahoo.com C++ 1 07-25-2005 04:48 PM
Garbage Collection kamran MCSD 1 04-04-2005 10:04 PM
Garbage Collection and Manage Code? Laser Lu ASP .Net 5 01-27-2004 03:48 AM
Debbugging help! (.NET 1.1 Framework Garbage Collection Problems) Cheung, Jeffrey Jing-Yen ASP .Net 3 07-10-2003 07:29 PM



Advertisments