[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Memory Allocation Hooks
- From: William Ahern <william@...>
- Date: Tue, 11 Jan 2005 21:46:29 -0800
On Tue, Jan 11, 2005 at 10:11:16PM -0700, Spencer Schumann wrote:
> > What I'm looking for is the ability to allocate a Lua state from my own
> > memory arena and disable Lua's garbage collection so that I can free the
> > entire Lua execution context in one go. Each Lua context will be running a
> > handful of extremely short scripts per instantiation.
>
> I think you'll find that garbage collection takes surprisingly little
> time. For executing small scripts, each with its own Lua state,
> creation and deletion of the Lua state will probably dominate
> processing time.
I wouldn't mind the garbage collection. It's just that in the average case
each client context for the server will probably take up similar amounts of
memory, and I have an inkling I _might_ get better performance by keeping
memory pools around which I can free instantly and reuse, rather than
shuttling smaller buffers back and forth from the heap with malloc(3) and
free(3).
Of course, this is all conjecture and using malloc(3) and free(3) directly
will probably suffice. It's just an option for the small chance performance
might benefit.
And, if I keep a single Lua state like you suggested then it wouldn't
matter. I'll never know till I test, though.