Memory Usage..

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Memory Usage..

Andrew Paton
Hi I got a quick question...

The first runing a pre-compiled script after opening a lua state I get an
allocation that never gets freed.  This only happens the one time it seems.
Heres a list of allocation prints from an Empty script (note I'm rounding up
the request to be a full 4 bytes).  Also Current and Max are in 4 byte
blocks unless they say bytes afterwards.

------ NEW SCRIPT 101
-- BUFFER SCRIPT Script.101
Max Memory Status is 19292 bytes, current is 19292 bytes Delta 908
LUA ++++ Alloc size of 68 set 0x814bfbd8 at achor 33 Current 4840 Max 4840
LUA ++++ Alloc size of 16 set 0x814bfc1c at achor 34 Current 4844 Max 4844
LUA ++++ Alloc size of 36 set 0x814bfc2c at achor 35 Current 4853 Max 4853
LUA ++++ Alloc size of 0 Ignoring 0 to Null
LUA ++++ Alloc size of 8 set 0x814bf644 at achor 10 Current 4857 Max 4857
LUA ++++ Alloc size of 0 Ignoring 0 to Null
LUA ++++ Alloc size of 0 Ignoring 0 to Null
LUA ++++ Alloc size of 0 Ignoring 0 to Null
LUA ++++ Alloc size of 4 set 0x814bf624 at achor 8 Current 4859 Max 4859
LUA ++++ Alloc size of 16 set 0x814bfc50 at achor 36 Current 4863 Max 4863
LUA ---- Free at 0x814bfc2c  Current loc is 4851 found the memory at anchor
35 anchor is -9 CurMem is 4854
Max Memory Status is 19452 bytes, current is 19416 bytes Delta 124
LUA ---- Free at 0x814bf624  Current loc is 4465 found the memory at anchor
8 anchor is -2 CurMem is 4852
Max Memory Status is 19452 bytes, current is 19408 bytes Delta -8
LUA ++++ Alloc size of 0 Ignoring 0 to Null
LUA ++++ Alloc size of 0 Ignoring 0 to Null
LUA ++++ Alloc size of 0 Ignoring 0 to Null
LUA ++++ Alloc size of 0 Ignoring 0 to Null
LUA ---- Free at 0x814bf644  Current loc is 4473 found the memory at anchor
10 anchor is -4 CurMem is 4848
Max Memory Status is 19452 bytes, current is 19392 bytes Delta -16
LUA ---- Free at 0x814bfbd8  Current loc is 4830 found the memory at anchor
33 anchor is -17 CurMem is 4831
Max Memory Status is 19452 bytes, current is 19324 bytes Delta -68
LUA ---- Free at 0x814bfc50  Current loc is 4860 found the memory at anchor
36 anchor is -4 CurMem is 4827
Max Memory Status is 19452 bytes, current is 19308 bytes Delta -16
Max Memory Status is 19452 bytes, current is 19308 bytes Delta 0

Note that the second alloc (LUA ++++ Alloc size of 16 set 0x814bfc1c at
anchor 34 Current 4844 Max 4844) never gets freed.
Now the second time through I get the same prints EXCEPT it didn't try to
alloc the 16 byte one.

Is this supposed to be happening like this???


Reply | Threaded
Open this post in threaded view
|

RE: Memory Usage..

Andrew Paton
Just a quick blurb for those who wanted to know that allocation was coming
from

Lobject.c line 60.

luaM_reallocvector(L, L->Mbuffer, n, char);

and heres the stack calls it goes through to get it.

lua_dobuffer
parse_buffer
protectedparser
luaD_runprotected
f_parser
LuaU_undump
LoadChunk
LoadFunciton
LoadString
luaO_openspace




Reply | Threaded
Open this post in threaded view
|

RE: Memory Usage..

Luiz Henrique de Figueiredo
In reply to this post by Andrew Paton
>luaM_reallocvector(L, L->Mbuffer, n, char);

Lua keeps this auxiliary buffer, which is quite useful.
I think it's never freed.
--lhf