# Is an embedded ruby interpreter safe to unload

**URL:** <https://www.ruby-forum.com/t/is-an-embedded-ruby-interpreter-safe-to-unload/88433>\
**Category:** Ruby\
**Created:** [March 11, 2007, 12:51am UTC](https://www.ruby-forum.com/t/is-an-embedded-ruby-interpreter-safe-to-unload/88433 "2007-03-11T00:51:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![llothar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3be4f8/32.png) [@llothar](https://www.ruby-forum.com/u/llothar)\
**Post date:** [March 11, 2007, 12:51am UTC](https://www.ruby-forum.com/t/is-an-embedded-ruby-interpreter-safe-to-unload/88433/1 "2007-03-11T00:51:29Z")

</div>

Hello ruby-talk,

when i use ruby embedded in a program where i call “ruby\_init”, do a  
few ruby magics and then call “ruby\_finalize”.

Will this free all used memory?

---

<div class="post-metadata">

**Author:** ![llothar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3be4f8/32.png) [@llothar](https://www.ruby-forum.com/u/llothar)\
**Post date:** [March 11, 2007, 10:50am UTC](https://www.ruby-forum.com/t/is-an-embedded-ruby-interpreter-safe-to-unload/88433/2 "2007-03-11T10:50:22Z")

</div>

On 10 mar, 20:51, Lothar S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hello ruby-talk,
> 
> when i use ruby embedded in a program where i call “ruby\_init”, do a  
> few ruby magics and then call “ruby\_finalize”.
> 
> Will this free all used memory?

You want to call ruby\_cleanup(0); instead, like ruby\_stop() does.  
ruby\_finalize() does not deal with threads.

---

<div class="post-metadata">

**Author:** ![llothar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3be4f8/32.png) [@llothar](https://www.ruby-forum.com/u/llothar)\
**Post date:** [March 12, 2007, 1:06am UTC](https://www.ruby-forum.com/t/is-an-embedded-ruby-interpreter-safe-to-unload/88433/3 "2007-03-12T01:06:16Z")

</div>

Hello gga,

> > Will this free all used memory?

g\> You want to call ruby\_cleanup(0); instead, like ruby\_stop() does.  
g\> ruby\_finalize() does not deal with threads.

Thanks,

i looked at the source and realize that there is no way to cleanly  
shutdown the ruby interpreter. This will just call all registered exit  
functions.

Very very bad because this means it’s very hard to use memory leak  
checking  
tools for extensions or much worse for systems that use ruby as an  
embedded  
interpreter.
