GC, and objects finalization (was: GC,again) 
Author Message
 GC, and objects finalization (was: GC,again)


Quote:
>   The set of problems that are solved by GC that are not solved by non-GC
>   is a  more significant set of problems.

I agree with this...

However I'm coming back with a problem for which nobody
have ever answer positively, including me :

Object finalization ! (alias destructor)
this problem arise in C++ and eiffel.

suppose
- I have objects that manage ressources that need finalization
   (eg socket, file, transaction...) in any case. This
   is very realistic (don't tell me it is avoidable as some told me ...
   or give me explications)
- one such objects is referenced by a user object, and
        the ressource object own pointer to the user object for internal
        policy. (eg: a filedescriptor point to the process owning it).
- user object must finalize itself, use the ressource, and only after this
        the ressource can be finalized !
- there is a GC. (a good one, the best !)
- The user object is no more used, but still reference and is refered by
        the ressource object

if the GC is a pure refcount one, then it cannot free
cycles in the pointer graph, so memory is not freed !

if the GC can destroy unreferenced cycles (cycle detection,
or mark and sweep...) then it find the two object as candidate for GC.
the user object and the ressource are refering each-other
simetrically.

1-
How can the GC triger finalization ? (easy?)
2-
How can he decide to finalize the user object, then the resource object,
and not the reverse ? (essential!)
3- what if one of the finalized object have reference to
living objects and ask them to link itself to them.
(eg: the dying filedescriptor ask to the filesystem
  to be kept in a list of cached filedescriptor)
I agree that it is strange, but why not ? It it really
possible, dangerous, interesting ?

My opinion is that GC only manage memory, not objects...
For classic programmers, IA programmers... there is no
problem if object are not finalized, but as I'm
building  system-aware softwares, finalization is essential
for system resources like files, networks objects, transcation ...

is there a sound theorical aproach that would
solve this problem, in a way similar to the one
GC ensure memory coherence.

If you solve this problem, then a GC in C++ would be
a rather easy job, isn't it ?
--
=======
Alain Coetmeur, Informatique-CDC R&D dept.



Tue, 25 Mar 1997 16:45:29 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Object Finalization and GC

2. GC and object finalization.

3. Why Files? (Was: Finalization and GC)

4. GC and resource finalization

5. GC and Aging, GC and Allocator Surveys available

6. To GC or not to GC?

7. reference counting vs. GC again

8. GC - again, :-)

9. Zombie Objects Leaks With Automatic GC

10. Finding un-gc-able objects

11. different object aging rates in GC

12. zillion objects and gc

 

 
Powered by phpBB® Forum Software