lua-users home
lua-l archive

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


Hello, 

Please forgive me if this was recently addressed. I didn't find anything
related in lua-l archive.

We're trying to track down some memory growth in our game, and came
across a difference between inserting (appending) array entries using
table.insert and direct array indexing t[n].  

It appears that luaL_setn is now directly setting the count into the
sizes list regardless of whether or not the field "n" exists.  I'm
assuming this is new to 5.1? 

Furthermore, it looks like the internal sizes table is is holding a
non-weak reference to tables for which setn has been called. 

Am I interpreting this correctly?  If so, would modifying the sizes list
to hold weak references create foreseeable issues?


Lua 5.1 (work2)  Copyright (C) 1994-2004 Tecgraf, PUC-Rio
> print(gcinfo())
17
> local t
> for i = 1,5000 do
>> t = {}
>> table.insert(t,1)
>> end
>
> print(gcinfo())
211
>
> t = nil
> collectgarbage()
> print(gcinfo())
177
>


Lua 5.1 (work2)  Copyright (C) 1994-2004 Tecgraf, PUC-Rio
> print(gcinfo())
17
> local t
> for i = 1,5000 do
>> t = {}
>> t[table.getn(t)+1] = 1
>> end
>
> print(gcinfo())
31
>
> t = nil
> collectgarbage()
> print(gcinfo())
17


Thank you,

Drew Powers