Release all images in MetalTextureHandler::releaseRenderResources#2316
Merged
jstone-lucasfilm merged 3 commits intoAcademySoftwareFoundation:mainfrom Mar 27, 2025
Conversation
…ePtr - which was causing memory leak. Refactoring to only store the ImageSamplingProperties - getMTLTextureForImage() refactor is ok, because the index for _imageBindingInfo is exactly the image->getResourceId()
a728c49 to
7395313
Compare
releaseRenderResources()MetalTextureHandler::releaseRenderResources
jstone-lucasfilm
approved these changes
Mar 27, 2025
Member
jstone-lucasfilm
left a comment
There was a problem hiding this comment.
This looks good to me, thanks @ld-kerley!
6ce8fd0
into
AcademySoftwareFoundation:main
35 checks passed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR addresses #2303.
This brings the MetalTextureHandler inline with the GLTextureHandler for releasing all the images when
nullptris passed.Without this - both CPU and Metal texture memory is being leaked if the image caches are flushed.
Recursively releasing the resources fixes the Metal texture memory leak, but that just highlighted the CPU side memory leak. This is due to the MetalTextureHandler also retaining an
ImagePtrin_imageBindingInfo. Removing theImagePtrfrom this storage fixes the memory leak, and it doesn't seem to be necessary to store the image, the only thing the image is used for is to access the resource ID - which is the same as the key to theunordered_map.