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

fix: textures memory leak #4455

Merged
merged 15 commits into from
Apr 25, 2023
Merged

fix: textures memory leak #4455

merged 15 commits into from
Apr 25, 2023

Conversation

pbosio
Copy link
Contributor

@pbosio pbosio commented Feb 17, 2023

Textures set to Materials were never disposed until the scene was unloaded.

  • Material was waiting for texture to finish loading before setting it reference, which lead to the race condition of changing the texture for that material before the previous texture was loaded, leaving an orphan texture.
    fixed by setting material reference to texture regardless of the texture download state.
  • Texture were never disposed, even if they were removed from all materials.
    fixed by disposing textures when reference count equals 0

note: texture are not removed from component manager after disposed, given the texture nature of disposable component means that the texture component should exist even if there are no reference to it.

fixes decentraland/sdk#607

how to test:
https://play.decentraland.org/?explorer-branch=fix/texture-leak
go around the world, textures and videos should be loading correctly

@pbosio pbosio self-assigned this Feb 17, 2023
@github-actions
Copy link
Contributor

@pbosio pbosio marked this pull request as ready for review April 18, 2023 21:52
Copy link
Contributor

@Kinerius Kinerius left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link

@kwsskulinski kwsskulinski left a comment

Choose a reason for hiding this comment

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

Textures load correctly. No issues detected.

@pbosio pbosio enabled auto-merge (squash) April 25, 2023 13:03
@pbosio pbosio merged commit cb2c913 into dev Apr 25, 2023
@pbosio pbosio deleted the fix/texture-leak branch April 25, 2023 13:43
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.

Materials leaking memory when are constantly being updated
4 participants