|
...in reading the book. Or look at the book online...mytableD = nilmytableD.refD = mytableDmytableD = {}I should probably buy the book. I'm starting to vaguely recall the idea of...Thanks for the replies. I'm curious... how does the algorithm work? How can Lua determine what does and doesn't need to be collected if it doesn't keep a reference count on an object?For example, it's clear that, after the code I had shown earlier is run, that tables A and B are in their own little reference group, but then the same can be said of the table "mytableC = {}" right after it is created. It's in its own little reference group, yet it shouldn't be garbage collected.
On Tue, Apr 29, 2014 at 10:57 PM, Andrew Starks <andrew.starks@trms.com> wrote:
On Tuesday, April 29, 2014, Spencer Parkin <spencertparkin@gmail.com> wrote:
There is no longer a reference to either table, yet they reference one another, so the tables are still around, right? If so, will these tables never get garbage collected?mytableA = nilConsider the following...mytablaA = {}
mytableB = {}
mytableA.refB = mytableB
mytableB.refA = mytableA
mytableB = nil
Lua does not use a reference counter for its GC and is able to avoid these issues. Since there is no path to these tables, they'll be collected.