Ok, I'm trying to figure out how to use ruby objects withing my application server.

What I need is to create ruby objects outside the scope of the interpretor.  Certain objects will be long-lived (created at server config) and others will be attached to a specific request and should be cleanly and reliably freed when the request is finished.  

Looking inside eval.c I see macros for "PUSH_SCOPE" and "POP_SCOPE" that look promising.  Perhaps I can create a global scope for the long-lived stuff and an inner scope for each request.  But both those functions are private to eval.c, and look pretty cryptic (I'm not sure what they really do).

Is there a public interface that I can use to accomplish this?   Is there some other way to implement my own memory management?  Other suggestions?

Thanks,
Ami.