# Closing and reloading compiled extensions

**URL:** <https://www.ruby-forum.com/t/closing-and-reloading-compiled-extensions/186575>\
**Category:** Ruby\
**Created:** [April 9, 2010, 3:19am UTC](https://www.ruby-forum.com/t/closing-and-reloading-compiled-extensions/186575 "2010-04-09T03:19:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nimai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9fc348/32.png) [@nimai](https://www.ruby-forum.com/u/nimai)\
**Post date:** [April 9, 2010, 3:19am UTC](https://www.ruby-forum.com/t/closing-and-reloading-compiled-extensions/186575/1 "2010-04-09T03:19:27Z")

</div>

I would like to be able to do the following:

1. Write and compile a C extension containing nothing but singleton  
methods defined on “self”.
2. Load the extension multiple times, attaching these methods to  
different objects.
3. Make changes to the extension, rebuild it, and replace the defined  
methods on select objects.

#1 is easy, #2 can be done by linking multiple singletons to the same  
method.

But #3 cannot be done, because I can’t dlclose() extensions.

Why not?

I know I could just create new instances of the interpreter.  
I don’t want to do this - I want to be able to create a unified,  
persistent object model that avoids the hassle of IPC, but still has the  
ability to load and unload dynamically compiled machine code.

Do I need to create my own extension loading/unloading library? Or is  
there an obscure feature or upstream patch I’m not aware of?
