[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Userdata environment
- From: Mike Pall <mikelu-0803@...>
- Date: Mon, 31 Mar 2008 19:04:47 +0200
Shmuel Zeigerman wrote:
> Mike Pall wrote:
>> If you're storing all your userdatas in the array part, a simple
>> 't.foo = nil' triggers the shrinking. If you'r storing them in
>> the hash part, a 't = nil' will do.
> My userdatas are keys in a weak keyed table. I've just tried your recipe in
> my application, both with t.foo=nil and with t=nil -- it didn't help.
Ooops, the 't = nil' advice was wrong. This doesn't force
creation of the array part (which would trigger resizing). :-(
The only way then is to add lots of dummy keys which have their
primary location in the array part, delete them again, and then
cause another resize:
for i=1,1e6 do t[i] = true end -- Adjust the 1e6 as needed.
for i=1,1e6 do t[i] = nil end
t.foo = nil
But maybe it's easier to drop the table and replace it with a
fresh one? (copy remaining elements as needed)