jzrake/lunum — Issue #4: manual collectgarbage() call maybe needed for large arrays
Author: jzrake
Created: 2012-02-08 17:30:20+00:00
State: open

The present design of Lunum is such that Lunum arrays are directly malloc'ed and then free'd by the __gc metamethod. Since lua_newuserdata is never used to allocate the array buffer itself, Lua thinks that it's using far less memory than may actually be being used, and so garbage collection cycles are not entered as often as they should be. Note that technically this is not a memory leak; all memory is cleaned up when Lua closes. In the future, this will change so that array buffers are Lua objects and therefore recognized by the garbage collector as accounting for total memory used by the Lua state.

For now, a call to collectgarbage() at the end of any loops that allocate large arrays will take care of poor performance.