Another option is to use a GC metamethod. Everytime the memory use crosses a threshold Lua runs the garbage collector, which calls the __gc metamethods for collectable userdata. This is a perfect time to check for memory overflow. -- Roberto