[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Tables and memory saving
- From: Michael Gerbracht <smartmails@...>
- Date: Sat, 24 Sep 2011 09:32:39 +0100
In article
<CAJt9-x4VQG=3TfzVEeoNSC9aMQ=6Xv2JNXEbZBNnc-M+WOORBA@mail.gmail.com>,
Matthew Wild <mwild1@gmail.com> wrote:
> On 23 September 2011 21:40, Michael Gerbracht <smartmails@arcor.de> wrote:
> > If I put everything into one table and try the same:
> >
> > TableMain = {}
> > TableMain.A = {<many entries>}
> > TableMain.B = {<many entries>}
> > TableMain.C = {<many entries>}
> >
> > TableMain.B = nil
> >
> > then the memory is not garbage collected by lua. I hope this is correct so
> > far.
> I think you are confusing garbage collection with the shrinking of tables.
> They are unrelated. An object (such as a table) is collected when there are
> no references to it. Your large table will be collected when you replace it
> with nil, regardless of whether it was in a variable or a table.
> In summary, don't worry about it. The space used by unrecovered table slots
> is negligible and rarely worth worrying about. Your actual data will always
> be garbage collected when not accessible.
Ok, thank you very much! I had in mind that I read somewhere that a table can
only be garbage collected as a whole. But I guess it was only related to the
table slot as you explained which can be neglected due to its small amount.
Michael