Skip to content

Add reference counting#2554

Merged
wixoaGit merged 7 commits intoOpenDreamProject:masterfrom
wixoaGit:ref_counting
May 7, 2026
Merged

Add reference counting#2554
wixoaGit merged 7 commits intoOpenDreamProject:masterfrom
wixoaGit:ref_counting

Conversation

@wixoaGit
Copy link
Copy Markdown
Member

@wixoaGit wixoaGit commented May 4, 2026

We now keep track of how many references every DreamObject has. Once it hits 0 we automatically delete the object, rather than depending/waiting on the .NET GC to collect it. DreamValue now has IDisposable so you can use using to automatically track a reference, and use [MustDisposeResource] to make it clear when a DreamValue reference will need to be tracked.

I'm not a fan of the annoying bugs this will introduce and added development friction, but this puts us closer to BYOND behavior in a lot of ways and opens the door for some big optimizations we need to make.

@boring-cyborg boring-cyborg Bot added Compiler Involves the OpenDream compiler Runtime Involves the OpenDream server/runtime labels May 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

This pull request has conflicts, please resolve those before we can evaluate the pull request.

# Conflicts:
#	OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs
#	OpenDreamRuntime/Objects/Types/DreamObjectParticles.cs
Comment thread OpenDreamRuntime/ByondApi/ByondApi.Functions.cs Fixed
Comment thread OpenDreamRuntime/Procs/InitDreamObject.cs Fixed
Comment thread OpenDreamRuntime/Procs/Native/DreamProcNativeRegex.cs Dismissed
Comment thread OpenDreamRuntime/DreamManager.cs Dismissed
Comment thread OpenDreamRuntime/Procs/InitDreamObject.cs Fixed
wixoaGit added 2 commits May 4, 2026 18:37
An inaccurate count led to not all locals being cleared on DMProcState disposal
Comment thread OpenDreamRuntime/Procs/InitDreamObject.cs Dismissed
@wixoaGit wixoaGit merged commit 098d1a0 into OpenDreamProject:master May 7, 2026
21 of 22 checks passed
@wixoaGit wixoaGit deleted the ref_counting branch May 7, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compiler Involves the OpenDream compiler Runtime Involves the OpenDream server/runtime size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants