lua-users home
lua-l archive

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


Request for clarification about references to internal table elements and
garbage collection.

Consider the following:

---

Example #1:

 outer = { "outer table"; inner = { "inner table" } }
 outer = nil

Statement #1:

 Outer table and all it contains will eventually be GC'd.

---

Example #2:

 outer = { "outer table"; inner = { "inner table" } }
 inner = outer.inner
 outer = nil

Statement #2:

 Though there is no longer a direct reference to the outer table, neither it
nor
 its' contents will be GC'd because there is still a reference to some part
of
 it.

---

Example #3:

 outer = { "outer table"; inner = { "inner table" } }
 outer.inner = nil

Statement #3:

 The inner table will eventually be GC'd but the outer table and all of its
 other contents will remain.

---

Taking the examples into account, are the above statements correct?

Thanks in advance,
David