Jason Felice wrote:

> I'm using libcall() to implement a plugin which corrects parentheses on
> every edit (TextChangedI/TextChangedP).  It works well, is snappy, and so
> forth, but it seems to make Vim SIGABRT "at random".  I tracked down the
> issue, and it seems that on Mac OS X (at least), if a dylib uses any thread
> local variables, a tlv key is allocated (inside dlopen()) every time the
> library is loaded.  These don't appear to ever go away, and there is a
> maximum number allowed per process.  dlopen() calls abort() if we run out.
> 
> Vim calls dlopen(), dlsym(), then dlclose() for *every* libcall()
> invocation.
> 
> I'm currently plotting a work-around involving referencing the library from
> inside itself so it will never be closed (Vim's dlclose() call won't be
> "balanced").  But I wonder whether and how to make Vim able to keep a
> library around.
> 
> Possible ideas:
> 1. A new libload()/libunload() pair of calls, wrapping dlopen()/dlclose()
> or the Windows equivalent.  A plugin can call libload() first, which will
> keep the library in memory.
> 2. A new, optional parameter to libcall(), saying it's OK to keep the
> library around, and maybe it is GC'd later?
> 3. ???

I would expect the dlclose() only to be needed to free up memory.
Does it do anything else, or is dlopen() needed for each libcall()?
Most likely not.

We can make a small cache of opened libraries.  Probably it's sufficient
to keep the last five or so.  Only keeping one would be simpler, but if
there are two plugins using libcall() then they would bite each other.

-- 
To define recursion, we must first define recursion.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to