Skip to content

Manage Metal objects with smart pointers - #3282

Merged
zcbenz merged 1 commit into
ml-explore:mainfrom
zcbenz:encoder-refactor-2
Mar 25, 2026
Merged

zcbenz merged 1 commit into
ml-explore:mainfrom
zcbenz:encoder-refactor-2

Conversation

@zcbenz

@zcbenz zcbenz commented Mar 20, 2026

Copy link
Copy Markdown
Member

Refs #3148.

For resources that are going to be transferred or kept, store them in NS::SharePtr, for temporary resources use autorelease(). In this way we don't have to manually call release(), which made the code very hard to modify, and it also makes the code exception-safe when we want to handle errors.

Have ran tests with OBJC_DEBUG_MISSING_POOLS=YES and verified that we are not adding leaks. And the impact of this change is actually small since most resources are only created once on initialization and not released on exit.

@angeloskath angeloskath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for doing that. It is so much better than before actually...

@zcbenz
zcbenz merged commit 282174d into ml-explore:main Mar 25, 2026
16 checks passed
@zcbenz
zcbenz deleted the encoder-refactor-2 branch March 25, 2026 02:19
@BrewTestBot BrewTestBot mentioned this pull request Apr 22, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants