lua-users home
lua-l archive

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


Hi all,

Thanks for the feed back. I've found some source code for a version of malloc/free by Doug Lea, at:

http://g.oswego.edu/dl/html/malloc.html

It's fairly fine tuned code, but hopefully it'll be good enough to give me sufficiently fast memory allocation. However, if anyone out there knows of simpler versions of malloc to implement, I'd be grateful for any links...

Thanks

George

Joshua Jensen wrote:

From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Richard Ranft

I don't know about the Lua internals, but for a memory management system I'd look into something like the frame-based memory system described by Steven Ranck in Game Programming Gems vol.1 on page 92. This system lends itself fairly well to gc and dynamic allocation.

The frame based allocation approach doesn't maintain headers for the
individual memory allocations.  In this way, it is more efficient for
allocation and freeing of blocks of memory.  Unfortunately, the extra
performance (both speed and size) doesn't lend itself well to the dynamic
memory allocation Lua performs.  Lua's memory blocks come in all shapes and
sizes, and they are never freed in a consistent sequential order.  The frame
based approach would only work well if Lua allocated a whole bunch of memory
and then freed it in reverse order.  With the way Lua is architected and the
dynamic nature of the scripts it runs, I'm certain this couldn't work for
Lua 5.0.

Josh



--
George Sealy, PhD                       email : george@arl.co.nz
Software Developer / Architect          phone : +64 3 477 2995
Animation Research Ltd