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

Memory Issue with troika-three-text #301

Open
TimJJTing opened this issue Jan 29, 2024 · 3 comments
Open

Memory Issue with troika-three-text #301

TimJJTing opened this issue Jan 29, 2024 · 3 comments

Comments

@TimJJTing
Copy link

TimJJTing commented Jan 29, 2024

It seems like there might be a memory issue caused by changing the material of the Text.

I'm attempting to incorporate some post-effects into my project, and one of them involves selective blooming for Text meshes. The usual approach for selective blooming involves rendering the scene twice. In the first render, the non-blooming objects (Text in my case) are replaced with something dark, and in the second render, the original material is restored.

I suspect that the automatically created DerivedMaterial is not properly disposed of after setting a material because I've noticed that when trying to implement this with Text meshes, the memory consumption keeps increasing until the page crashes. To be specific, the automatically created DerivedMaterial from the first render are likely not disposed during the material restoration process in the second render.

Please see codesandbox for the issue. Post-processing parts are skipped for simplicity.

@lojjic
Copy link
Collaborator

lojjic commented Jan 29, 2024

Thanks, it seems likely you're correct about disposal.

How are you measuring the memory consumption? Is this JS heap memory or GPU memory, or both?

@lojjic
Copy link
Collaborator

lojjic commented Jan 29, 2024

Not to ignore the issue, but in your specific case couldn't you just temporarily change the color to black rather than replacing the whole material?

@TimJJTing
Copy link
Author

TimJJTing commented Jan 29, 2024

Thanks, it seems likely you're correct about disposal.

How are you measuring the memory consumption? Is this JS heap memory or GPU memory, or both?

I measure JS allocated memory with the stats component. See the top left corner in the codesandbox, the memory consumption keeps rising. Not yet sure about GPU memory though.

Not to ignore the issue, but in your specific case couldn't you just temporarily change the color to black rather than replacing the whole material?

Yes, I think this will fix my problem.

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

No branches or pull requests

2 participants