lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2009/12/9 steve donovan <>:
> On Wed, Dec 9, 2009 at 12:29 PM, Jerome Vuarand
> <> wrote:
>> One way to avoid problems with libc runtimes on windows is to link
>> them statically. I did that on one of my projects and it can greatly
>> simplify deployment. It slightly increases DLL sizes, but that's still
>> reasonnable (iirc lua51.dll grew from 160k to 250k or so).
> That's true, and it is guaranteed to work. But then every extension
> .dll has to be statically linked as well.

No, that's not true. You can mix DLLs using different runtime libc, as
long as you follow some rules. One of them is to avoid passing
pointers allocated with one runtime and try to free the memory with
another runtime. But there is little reason a Lua extension would do

For example, memory allocated by a userdata constructor, will be
deallocated by its __gc metamethod, which is likely to be implemented
in the same DLL, using the same C runtime (even if lower on the C call
stack there is code using other runtimes). This may however lead your
program to have several independent heaps. A way to avoid that is to
avoid malloc in C modules, and only use lua_newuserdata (or the
lua_Alloc directly) for memory allocation.