godotengine / godotengine/godot-docs
`Class: Reference` needs a cycle warning.
- Dominant language
- reStructuredText
- Stars
- 5.7k
- Forks
- 3.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 25
Description
It is possible to create a cycle that would prevent a `Reference` from freeing.
```
extends Reference
class_name Cycle_Test
var cycle
func _init():
cycle = self
```
This possibility should be noted in the `Class: Reference` documentation. The documentation as written implies this shouldn't ever happen. It should also mention the existence of `WeakRef`.
It's also possible to create a cyclical memory leak with just a dictionary:
```
func createCycle():
var a = {}
a.a = a
```
It's possible I'm merely over reacting. After reading the "Best Practices" section, subsequently redesigning a large portion of my project, and then debugging why an `Object` with an explicate`queue_free()` works as expected but a `Reference` does not for two days, I feel like some warning in the documentation is justified.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.