Re: Why does LuaJIT have its own allocator?

  • From: Coda Highland <chighland@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sat, 15 Sep 2012 09:54:17 -0700

On Sat, Sep 15, 2012 at 9:38 AM, Matt Campbell <mattcampbell@xxxxxxxxx> wrote:
> Hello:
>
> I've noticed that LuaJIT has its own allocator, which it uses by default on
> all platforms. Why is this? Wouldn't LuaJIT achieve lower memory footprint,
> through greater pooling of memory with the host application and other
> libraries, if it used the libc-provided malloc?
>
> I realize that LuaJIT has to use its own allocator on x64, to ensure that
> all addresses used by LuaJIT are below the 2 GB boundary. But on other
> platforms, I wonder if the use of a custom allocator is a case of premature
> optimization. Of course, LuaJIT is all about optimization. But I'm curious
> about why this particular optimization was chosen.
>
> Thanks,
> Matt
>

Because the system allocator is unpredictable and usually slow. LOTS
of high-performance applications that need to do a lot of memory
management bring their own arena implementations.

/s/ Adam

Other related posts: