Sometimes you need to store some Godot objects or references in a Kotlin singleton. This can cause some leaks when the program ends because you have to manually free objects and have the references collected.
This issue is fixed by using the delegate
godotStatic on singleton properties. Those properties will be freed once the JVM ends. They automatically handle
Reference. You can also freely set a new value and the previous one will be immediatly freed.
Only use it on a singleton, otherwise all the properties of all instances are going to be kept alive until the end of the JVM.
1 2 3 4 5 6 7 8