Embedding Ruby: Potential memory leaks?

I’d like to embed ruby into a C program. Are there any potential
memory leaks regarding rb_str_new(), rb_define_readonly_variable(),
etc.?

How can I be sure that the objects generated by rb_str_new() get
cleaned up? Are there any old references left when I call
rb_define_readonly_variable() more than once with the same variable,
but different data?

I'd like to embed ruby into a C program. Are there any potential
memory leaks regarding rb_str_new(), rb_define_readonly_variable(),
etc.?

no,

How can I be sure that the objects generated by rb_str_new() get
cleaned up? Are there any old references left when I call
rb_define_readonly_variable() more than once with the same variable,
but different data?

ruby use a mark/sweep garbage collector

Guy Decoux

ts decoux@moulon.inra.fr writes:

How can I be sure that the objects generated by rb_str_new() get
cleaned up? Are there any old references left when I call
rb_define_readonly_variable() more than once with the same variable,
but different data?

ruby use a mark/sweep garbage collector

VALUE foo = rb_str_new2(“bar”);

Some steps later … How do I know that the mark/sweep garbage
collector hasn’t removed my new object?

VALUE foo = rb_str_new2("bar");

....

Some steps later ... How do I know that the mark/sweep garbage
collector hasn't removed my new object?

The object is on the stack, it will be marked by the GC . see
[ruby-talk:62371]

http://www.ruby-talk.org/62371

Guy Decoux