- No objects derived from ''gc'' seem to run their destructors...I noticed that in the sample all the classes derived from gc contained simple data types that wouldn''t care if the d''tor wasn''t run (ints for example) - although my d''tor seemed to be run normally when I derived from ''gc_cleanup''
- How can I ensure all inactive objects are deallocated? GC_gcollect(); ?
- Do I actually need to call GC_init() usually?
- I saw a note to the effect that arrays of objects would delete properly under some conditions, the example they gave used ''delete'' rather than ''delete[]''...would ''delete[]'' have the same problem?
- Do I need to do something to shut down the GC (as in inverse of GC_init() )?
- do I always need to call new like this: ''A* a = new(UseGC) A(bob);''
Garbage Collection
First of all, I''m not trying to start a ''to GC or not to GC'' type of flame war!
What I''m interested in knowing is, has anyone tried using the Hans Boehm conservative garbage collector in anger? I''m just about to start coding something that does a lot of graph analysis type of things & I''m expecting to end up with fairly huge numbers of cyclic references etc so want an effective way of easily (& preferably) managing object lifetimes especially as when researching the algorithms I intend to use I realised that ther will be a lot of adding & removing reference to objects. Basically I figured that the easiest way out would be to do garbage collection, especially given that the HB GC is apparently only 27% slower than doing it by hand (for the memory allocation related operations, not the whole program...) + it obviously reduces the complexity.
I''ve played a little bit with the GC, but I haven''t yet been able to figure a few things out;
I''m pretty sure you can set up the Boehm GC to call destructors, but it''s not automatic.
Have you considered doing without destructors? Usually, you can do without. Do your destructors do anything but free memory anyhow?
- Josh
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement