I read some article about ruby garbage collector and many mentioned about circular reference object can not be cleared. This article mentioned about circular reference but I'm not sure whether it will cause the problem. Any one could give some examples of how to create a circular references?

有帮助吗?

解决方案

I read some article about ruby garbage collector and many mentioned about circular reference object can not be cleared.

That's absolutely not true.

Any one could give some examples of how to create a circular references?

Most trivially like this:

arr1 = []
arr2 = [ arr1 ]
arr1 << arr2

However, as I said (and as the answer to the question you linked also points out), Ruby's GC will have absolutely no problem collecting arr1 and arr2 after they go out of scope.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top