[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Tracing Memory Grabbers
- From: Enrico Colombini <erix@...>
- Date: Fri, 16 Mar 2012 14:56:50 +0100
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