lua-users home
lua-l archive

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


On Tue, Apr 5, 2011 at 7:01 AM, C++ RTMP Server <crtmpserver@gmail.com> wrote:
> What would be the purpose of lua_alloc function?

lua_alloc can be used for purposes unrelated to implementing a faster allocator:

- allows lua with crazy systems that don't have a heap at all
- allows you to redefine to a slower allocator that checks for memory
leaks, and records usage statistics
- when lua is embedded inside a runtime env that requires all memory
to come from a particular heap, or that
  has a heap per component, or where you want to track and assign all
memory used to specific components

I've used it for the last two. The result was slower, not faster.

You're getting some kick-back because the only allocator you should be
able to beat by using an your own
custom allocator that took you less than a week to write is such a bad
allocator that you shouldn't
be using it at all, for anything. Terrible allocators used to be
common, but have gotten much better in the
last 10 years.

Cheers,
Sam