godotengine / godotengine/godot-docs

Usage of IDisposable & Free() in C#

Open
#3,924 7 comments 0 reactions 1 assignee Claimed by @neikeq View on GitHub
area:manual enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

Godot 3.2.2

I've been searching/asking for a definitive answer to this question both in the [QA section](https://godotengine.org/qa/79183/idisposable-%26-free-in-c%23), [Reddit](https://www.reddit.com/r/godot/comments/ibaq0d/idisposable_free_in_c/) and on Discord, but I have yet been able to find an answer, or even anyone who dares to make a guess.

So, here's a request for documenting the intended usage of the `IDisposable` interface and `Free()`, present in both `Godot.Reference` and `Godot.Object`, and thus all sub classes of these two.

Sub classes of `Godot.Reference` are reference counted, but since the class also implements `IDisposable` it is a fair assumption that `Dispose()`should be called - but this is meant to be a one-time call which does not play well with a reference counted types.

- How are these two memory management systems intended to interact?
- Who is meant to call `Dispose()` and when?
- Who is mean to call `Free()` and when?
- Are we supposed to call both `Free()` and `Dispose()`?
- When does the engine call these methods, i.e. when does ownership of an instance pass to the engine?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.