[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.new in 5.3?
- From: Mike Pall <mikelu-1311@...>
- Date: Mon, 25 Nov 2013 15:58:28 +0100
Javier Guerra Giraldez wrote:
> On Sun, Nov 24, 2013 at 6:53 AM, Mike Pall <mikelu-1311@mike.de> wrote:
> > It doesn't change the sizes, it doesn't
> > shrink or reset the table (which would be much less useful in
> > practice).
>
> but at some point it would be resized, right?
Initially, usually.
> what happens if there's
> a big table, i clear() it, and then add a single key/value. would it
> stay big forever? until the next garbage collection? or immediately,
> as the set function detects it's way oversized?
It would stay big. But that's neither the common case nor the
specific use case: recycling from the same context, with similar
usage patterns.
> if the later, then how am i supposed to 'recycle' big structures?
That's a very different use case. It's not _recycling_ that you're
after, you want it to _release_ its memory.
But to answer the question: you don't. You give it a new table and
let the GC do its work. There's no need for an extra function for
this use case. Never second-guess the GC.
--Mike