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

TransformControls: Added geometry and material dispose to dispose(). #16065

Merged
merged 1 commit into from
Mar 27, 2019

Conversation

arodic
Copy link
Sponsor Contributor

@arodic arodic commented Mar 26, 2019

This should fix #15743

@arodic arodic force-pushed the patch/TransformControls-memory-leak branch from d872779 to 7970c45 Compare March 26, 2019 12:20
@arodic arodic force-pushed the patch/TransformControls-memory-leak branch from 7970c45 to 0f39a18 Compare March 26, 2019 12:26
@arodic
Copy link
Sponsor Contributor Author

arodic commented Mar 26, 2019

Note: this fix hasn't been confirmed yet! Do not merge yet.

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 26, 2019

this fix hasn't been confirmed yet! Do not merge yet.

Hint: Consider to do a draft PR in such cases: https://github.blog/2019-02-14-introducing-draft-pull-requests/

@mrdoob mrdoob changed the title Added geometry and material dispose to TransformControls.dispose(). TransformControls: Added geometry and material dispose to dispose(). Mar 26, 2019
@mrdoob mrdoob added this to the r104 milestone Mar 26, 2019
@mrdoob mrdoob merged commit 975b91f into mrdoob:dev Mar 27, 2019
@mrdoob
Copy link
Owner

mrdoob commented Mar 27, 2019

Thanks!


if ( object.material ) {

object.material.dispose();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to crash on array materials.

Copy link
Contributor

Choose a reason for hiding this comment

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

Disposing objects needs to be consolidated into a single place. For example, this is what I currently have and I re-use it everywhere: https:/infamous/infamous/blob/39ab9e3854f32911c1bc53ac0dca0d1696f4242d/src/utils/three.ts#L10-L61

It is better than writing duplicate dispose code all over the place.

And also, now that I realize based on discussion in #15743, this does not dispose textures (which may be something you intend to do in some cases).

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is going to crash on array materials.

TransformControls does not assign multiple materials to its renderable 3d (helper) objects so this should be no issue.

Copy link
Collaborator

@Mugen87 Mugen87 Jan 3, 2020

Choose a reason for hiding this comment

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

Disposing objects needs to be consolidated into a single place.

I think it's better to define just an interface for disposal operations ( dispose()) and let the respective class decide how to free things. In this way, it's not necessary to centralize component-specific stuff into a single place.

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 with TransformControls
4 participants