Re: Are FFI namespaces/resources independent per VM?

  • From: Mike Pall <mike-1301@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 23 Jan 2013 11:38:25 +0100

demetri wrote:
> Suppose I have a long-lived process hosting a LuaJIT VM that, over its
> lifetime (days/weeks), will want to load many different (say, hundreds) .so
> libraries through FFI (this is a scientific computing application and the
> .so libraries are generated-code per-workload for accessor/serializer/etc.
> functions).
> 
> Between each workload (i.e. between each .so load) we shut down the LuaJIT
> VM and instantiate a new one.

A lua_close() deallocates *all* resources of the VM. If not, then
this is a bug.

> Is this enough to ensure that we don't run into any kind of resource
> exhaustion from loading so many C libraries?

I guess your more serious problem is with the dynamic loader.
dlclose() is kind of buggy in some implementations, since it's not
used that much. You should do some extensive testing (load/unload
1e6 times in various patterns).

Also, you'd have to monitor the shared libraries themselves for
potential leaks on unload. Many common libraries are leaky or get
into trouble when unloaded or later, when reloaded. Looks like
you're generating the libraries yourself, so this should be
feasible.

--Mike

Other related posts: