On Tue, Apr 5, 2011 at 2:25 PM, Jan Behrens
<public@magnetkern.de> wrote:
My own lua_Alloc function started with code similar to the following:
if ((*counter + nsize - osize) > PGLUA_MEMORYLIMIT) return NULL;
*counter += nsize - osize;
I realized that due to the new interface I need to make another distinction of
cases to track memory usage (depending on what osize really means). According
to my own (personal) taste, it would be nice to have an extra argument passed
to the lua_Alloc function, instead of (ab)using osize for that. Old code may
be broken anyway due to the subtle changes, which have been already
introduced.
What really should happen is that there should be an API function which allows a memory cap to be set, something like
lua_setmaxmemory(L,8388608);
Setting a memory cap is such a common thing to do that it really should be trivial to do it. Not that writing a custom allocator is a huge deal but it does require some development/testing effort that would be better spent elsewhere.