-
Notifications
You must be signed in to change notification settings - Fork 14
macOS: fix memory leak in Metal driver #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rkitover
wants to merge
1
commit into
renderbag:main
Choose a base branch
from
rkitover:macos-metal-memleak-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+21
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it could be a likely culprit of the current memory leaks. Do you know which part of the enclosed code is responsible for needing the pool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of these are apparently the major memory leak I am seeing in BanjoRecomp, this fix just releases the
MTLSTRlabel string which is an autorelease string and accumulates in that code path.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so merging this and the other related PRs won't fix the major leak yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A friend asked me to look at the leak in BanjoRecomp. I don't think there is one in plume, these were the first ones I identified but they are minor correctness issues. It looks like I need to look into rt64 in more depth for the major memory leaks.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on the
MTLSTRbit for my understanding? I was under the impression from looking atmetal-cppthatMTLSTRis basically the same asCFSTR, which states:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding here was wrong, you are correct that
MTLSTR()objects do not need to be autoreleased.The autorelease pool is actually for the
commandBufferWithUnretainedReferenceswhich needs to be autoreleased.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing what we have I see two different uses of
commandBufferWithUnretainedReferences.MetalCommandList::begin() and MetalCommandList::end() split this responsibility by not using the auto release pool and just calling
releaseon the end method.The other uses seem to wrap it in the auto-release pool, but a static code review alone doesn't really tell me whether that actually releases the command buffer or not. I'm not finding much documentation on that regard.
Then remains this particular use, where the command buffer is requested but no auto release pool is used, which is what the PR fixes.
It'd be good to get a solid confirmation on whether the auto-release pool actually works or not, because as far as I see, doing what MetalCommandList does could also be a fix that is much easier to understand and review than the auto-release behavior.