Skip to content
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

dispose material textures when disposing GLTFInstance #2600

Merged
merged 1 commit into from Jul 22, 2021

Conversation

ukito-pl
Copy link
Contributor

Resolves problem with memory overflow when GLTFInstance object is being repeatedly created and disposed.

Reference Issue

Fixes: #2139

for (const propertyName in material) {
const propertyValue = (material as any)[propertyName];
if (propertyValue instanceof Texture) {
propertyValue.dispose();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good call! Not sure how we went this long without noticing our textures needed disposal. Did you verify this fixes the leak?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the example I supplied in #2139 doesn't create memory overflow when tested on my local build with proposed fix.

@elalish elalish requested a review from a user July 21, 2021 15:47
@elalish elalish merged commit bfeac75 into google:master Jul 22, 2021
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.

Memory leak after repeated adding and removing model-viewer component to the DOM
2 participants