• Subject: Re: Memory leak?
• From: Hans Hagen <pragma@...>
• Date: Wed, 30 Jan 2008 18:18:16 +0100

```Mark Meijer wrote:
```
```Sorry, I didn't see the last two replies (by Hans and Alex resp.)
until I posted my previous one.
```
```
never mind -)

in the original post there was a for i=1,n loop

```
when using (i)pairs one should be real carefull with such 'created holes'; the same is true for 0/1 based indexed tables
```
(lucky us that in most realistic cases things are quite intuitive)

t = { }

t[1], t[2], t[3] = 1, 2, 3 print("size",#t)

for k,v in ipairs(t) do print("a ipairs",k,v) end
for k,v in pairs (t) do print("a pairs ",k,v) end

t[0], t[8] = "not used", "not used" print("size",#t)

for k,v in ipairs(t) do print("a ipairs",k,v) end
for k,v in pairs (t) do print("a pairs ",k,v) end

t[2] = nil print("size",#t)

for k,v in ipairs(t) do print("a ipairs",k,v) end
for k,v in pairs (t) do print("a pairs ",k,v) end

t = { } print("")

t[0], t[8] = "not used", "not used" print("size",#t)

for k,v in ipairs(t) do print("b ipairs",k,v) end
for k,v in pairs (t) do print("b pairs ",k,v) end

t[1], t[2], t[3] = 1, 2, 3 print("size",#t)

for k,v in ipairs(t) do print("b ipairs",k,v) end
for k,v in pairs (t) do print("b pairs ",k,v) end

t[2] = nil print("size",#t)

for k,v in ipairs(t) do print("b ipairs",k,v) end
for k,v in pairs (t) do print("b pairs ",k,v) end

-----------------------------------------------------------------