From: viisi@... (Andreas Riedl) Date: 2001-05-18T02:11:24+09:00 Subject: [ruby-talk:15333] how to use garbage collection relyably? hi! how is garbage collection intended to be used? is VALUE x = rb_ary_new(); VALUE y = rb_ary_new(); ensured to work correctly? or must it be written as: VALUE x,y; x = rb_ary_new(); rb_register_addr(&x); y = rb_ary_new(); rb_unregister_addr(&x); to prevent the allocation of 'y' to accidentionally recycle 'x''s space, before any other object is set up to mark 'x'. or should i 'GC.disable' globally and manually call rb_gc() periodically from some save location. (where it is ensured that there don't exist any temporary VALUE's) btw: i wonder how does it work in the ruby core? e.g. in 'array.c': ----------- snip -------------- rb_ary_new2(len) long len; { NEWOBJ(ary, struct RArray); OBJSETUP(ary, rb_cArray, T_ARRAY); . . . ary->ptr = ALLOC_N(VALUE, len); } ----------- snap -------------- what prevents 'ALLOC_N(VALUE,len)' from just recycling 'ary', if 'ruby_xmalloc' decides to call 'rb_gc'? ciao, andi