Re: luaL_newstate vs lua_newstate

  • From: Mike Pall <mike-1208@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 22 Aug 2012 21:18:44 +0200

Stefan Hett wrote:
> Would things be different if one makes use of a customized allocator
> already (i.e. specify that other allocator as the first parameter to
> lua_newstate()?

Minimum alignment is 8 bytes for the returned memory (like malloc).
No other restrictions on 32 bit systems. On x64 systems, it needs
to return addresses in the low 2GB.

> If the allocator is as fast as the one provided with
> LuaJIT are there any other expected pitfalls/problems/downsides of
> sticking with lua_newstate()?

Well, if you manage to beat the performance of the builtin
allocator (for use with typical Lua programs), then I'd like to
hear from you.

OTOH none of this is future-proof. LuaJIT 2.1 is going to ignore
the user-definable allocator and always uses its own integrated
allocator and garbage collector (which requests big aligned pages
from the OS).

--Mike

Other related posts: