extism / ruby-sdk

Extism Ruby Host SDK - easily run WebAssembly modules / plugins from Ruby applications
https://extism.org
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

Functions created with `extism_function_new` should be freed using `extism_function_free` #12

Closed zshipko closed 11 months ago

zshipko commented 11 months ago

Since Ruby doesn't have finalizers and the ruby-sdk ties host functions to a Plugin host environment, I think we could loop over Plugin#functions and call extism_function_free here: https://github.com/extism/ruby-sdk/blob/48454be5f257ed0b22009c3d7ed2f2c1f78a22ce/lib/extism/plugin.rb#L100

^ That approach won't work, we need to call extism_function_free when the HostEnvironment or ExtismFunction is garbage collected since each host function might be used in multiple plugins.