A,B,C三个struct,A持有B的引用,B持有A的引用,C持有B的引用,如下所示
```
type A struct {
b *B
}```
```
type B struct {
a *A
}```
```
type C struct {
b *B
}```
那么它们会被gc么,是不是会造成内存泄漏?
没问题的,A和B的实例之间相互引用是可以被回收的,只要这两个实例没有在其它地方被引用到
In a tri-color collector, every object is either white, grey, or black and we view the heap as a graph of connected objects. At the start of a GC cycle all objects are white. The GC visits all roots, which are objects directly accessible by the application such as globals and things on the stack, and colors these grey. The GC then chooses a grey object, blackens it, and then scans it for pointers to other objects. When this scan finds a pointer to a white object, it turns that object grey. This process repeats until there are no more grey objects. At this point, white objects are known to be unreachable and can be reused.
https://blog.golang.org/go15gc
https://groups.google.com/forum/#!topic/golang-nuts/tzvgeBEW1WY
#2