From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-04-09T08:37:15+09:00 Subject: Re: [embedding] keeping track of non-exported global variables On Wed, 09 Apr 2003 09:10:36 +0900, Mauricio Fern�ndez wrote: >> >> Objects::~Objects() { >> rb_gc_unregister_address(&objects); >> } >> >> Unregistering all objects: Is this dtor sufficent ??? >> >> Should I manualy erase each element first ??? >> or is this unnecessary? > > If I got it right, not. The GC won't mark them, and they will be swept > away. Me asking many silly questions and you answered them, thanks 1000 times :-) Finaly my class looks like this.. Objects::Objects() { objects = rb_ary_new(); rb_gc_register_address(&objects); } Objects::~Objects() { // dispose array and flush all elements rb_gc_unregister_address(&objects); /* mass destrurction. GC can no longer can mark the elements in the Array and therefore they will all get swept. */ } void Objects::Register(VALUE object) { rb_ary_push(objects, object); } void Objects::Unregister(VALUE object) { rb_ary_delete(objects, object); }