lua-users home
lua-l archive

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


Mike Pall wrote:
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

The whole point of garbage collection is to free the program
from being engaged with memory issues :)

But maybe it's easier to drop the table and replace it with a
fresh one? (copy remaining elements as needed)

I've been thinking about that. It'd be a viable solution if we knew that the table contains few elements at every given moment. But even then, the application would be in charge of doing that task from time to time (adding in fact a "local" garbage collector to Lua).

--
Shmuel