One question---does your allocator just assign the next available free
spot? And is free() implemented? To me, the difference can be explained by
Lua freeing some garbage that isn't reflected in your custom allocator.
The placement algorithm is a little smarter than simply 'next free spot’ in an effort to reduce fragmentation. It maintains a free list of deallocated cells, so it does implement free() properly. Trust me, when it doesn’t everything blows up very quickly with this little RAM! I’m pretty sure of the allocator’s correctness, even though the fragmentation behaviour could probably be improved.
Cheers,
Tom