[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Memory leak?
- From: Hans Hagen <pragma@...>
- Date: Wed, 30 Jan 2008 13:51:25 +0100
Patrick Donnelly wrote:
I'm pretty sure this has to do with tables remembering "old" keys.
This is important for next() when you try to check the next key/value
pair 'after' removing the last...
e.g.
for k in pairs(t) do t[k] = nil end
Note that if you try to call next() with an invalid key (one that was
never in the table), you get an error raised.
While assigning a new table does "fix" it, there probably should be
some sort of collection of these unused keys.
Note: I'm sure some of what I said is technically misleading (due to
my misunderstanding), but I hope the general idea is understood.
i may be wrong but i think that
somevar = nil
is actually defining a variable; try this ...
a = nil
function abc() print(a) end
a = 'value is not nil'
abc()
a = nil
abc()
a = 'value is set again'
abc()
so, in your case, once you have a t[10] defined you can set it's value
to nil, but that does not dispose the variable, only its value
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------