From: Harry Ohlsen Date: 2004-02-06T11:49:59+09:00 Subject: Re: Is there any way to mark an object as "always in use" (specifically, in a C extension)? nobu.nokada@softhome.net wrote: >>(2) is there some way I can mark all of those objects as >>always being in use, so that they'll never be considered for >>garbage collection; > > > You may want to use rb_gc_register_address()? Thanks. I'll look that up! > Is it the single big hash in process, but not per instance, > right? There's a single hash table, that's not registered as a Ruby object. However, the data stored in the table are all VALUE objects obtained from rb_str_new2(). There is a single instance of an object implemented in C that Ruby *does* know about, and that object holds many references to the strings in the hash table. For one document, for example, there were 2.7 million references to around 87,000 strings, totalling just under 267,000 bytes of text. It's the ..._mark() function of that class where I currently mark all of the strings. While it doesn't *seem* to be taking a huge amount of time to do that each time, I'd like to try to avoid it, just to see whether that really is the case ... ie, see whether the actual time being used is significant. In any case, if it's easy to fix, it just doesn't make sense to keep marking them over and over. > 2. make the hash a hidden instance variable of any class, if > exists. That might work, but as things are currently, Ruby doesn't know anything about the hash table. It's simply an implementation detail of the extension. However, if I can't work out how to get it working with rb_gc_register_address(), I'll see if I can do something along these lines. Thanks for the suggestions! Harry O.