lua-users home
lua-l archive

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


On 16/03/2012 14.48, Luiz Henrique de Figueiredo wrote:
That's correct for Lua 5.1 but not for 5.2 because the manual says:

    When ptr is NULL, osize encodes the kind of object that Lua is allocating.
    http://www.lua.org/manual/5.2/manual.html#lua_Alloc

So you need to handle the case ptr==NULL separately if you want to track
total memory use. Or if you're not interested in the info osize provides,
just do
	osize = (ptr==NULL) ? 0 : osize;

Didn't notice that change. Thanks for pointing it out!

Does this way of measuring allocated memory give the same result as just asking the collector?

  total = lua_gc(L, GCCOUNT, 0) * 1024 + lua_gc(L, GCCOUNTB,0);

--
  Enrico