lua-users home
lua-l archive

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


I made a memory pool out of userdata once by setting up a few generic
for the udata classes that overwrites their __gc method to shove the
thing back into a freelist.  The allocators would also take from this
freelist.  It can be done quite easily with a little Lua script and
you don't have to change any of your code to support it aside from
running the functions over the class when loaded.

That would address the cost of having a lot of allocations and deallocations of a few bytes of memory, I guess. But it wouldn't do anything about my current concern, the cost of garbage collection itself, right? Because it doesn't in any way change how the garbage collector behaves... just what happens after the object has been collected.

// Niklas