[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: GC order
- From: "Nick Trout" <nick@...>
- Date: Thu, 8 May 2003 17:21:15 -0700
> So Lua is free of circularity problems? Does this mean that
> if A referred to B and B referred to A, there is a way in Lua
> one can somehow cause garbage-collection on either A or B? I
> was under impression it would have been the case where
> neither one would get GCed. I guess I am not sure what a
> circularity problem is. Hmm...
They are collected as shown here:
Lua 5.0 Copyright (C) 1994-2003 Tecgraf, PUC-Rio
> = gcinfo()
18 37
> a,b = {},{}
> a.b, b.a = b, a -- mutual reference
> a.string = string.rep('a', 100000)
> = gcinfo()
165 330
> b.string = string.rep('a', 100000) -- aha no duplicated strings!
> = gcinfo()
165 330
> b.string = string.rep('a', 100001)
> = gcinfo()
263 526
> collectgarbage()
> = gcinfo()
239 477
> a,b = nil,nil -- we now have 2 unreachable tables
> = gcinfo() -- not deleted yet
239 477
> collectgarbage()
> = gcinfo() -- collected the island
31 61