Comments (5)
I have debugged the example and it seems the internal program cache does not retain outdated program references. When you call material.dispose()
, the renderer checks if an instance of WebGLProgram
is still required and if not, releases it and removes internal references. The code that triggers these operations is:
three.js/src/renderers/WebGLRenderer.js
Lines 711 to 731 in 0f4df91
When a program is removed, keep in mind that it is not immediately removed from memory. That happens when the GC runs and we can't influence when the JS environment decides to run it.
from three.js.
Hello @Mugen87, thank you for looking into this issue. I forced garbage collection (in memory profile tab its 5th icon, first is to take heap memory snapshot), but unfortunatelly it didnt garbage collectied it in next snapshot.
What seems to be leaking is WebGLProgram from webgl context, a gpu resource, not the class wrapper which is called WebGLProgram too. To confirm this I renamed wrapper class to be sure.
It looks like this WebGLProgram program instance reference is still somewhere and it is preventing garbage collection. I already spend few hours on this and I am more familiar with the issue, but I am not able to figure out this out yet.
I also found some "similar" issue from that past. I am not sure if its related or not yet.
#19645
from three.js.
I also found some "similar" issue from that past. I am not sure if its related or not yet.
#19645
It is not related, imo. Render states have no references to programs.
from three.js.
I've checked the relevant code base again I don't think the root cause is on our side. Especially the behavior you have described here makes me think this is a browser related issue:
Number of instances seems to be capped at ~131 for my computer which is very strange.
Also then it seems like all above 131 will get deleted correctly which is even more weird.
To me, this does not look like a memory leak. I suspect what we see is some sort of cashing mechanism of the browser to retain programs for a potential later use. Even if an app does not use a program for rendering anymore, it might be use it at a later point. Next to optimizations on engine levels, WebGL implementations apply optimizations as well to avoid unnecessary overhead. If the browser caching is implemented correctly, is a different question.
But to be honest, if there is no ongoing growing memory allocation that eventually slows down the app or crashes the tab, I would not worry about 131 instances of WebGLProgram
retained somewhere in memory. If you insist to report it, do it here: https://issues.chromium.org/issues.
from three.js.
I kind of agree with your conclusion. If I find some other reason or evidence I will report it.
I tried several code changes to get rid of those WebGLPrograms but I was unable to achieve it.
Also thanks for the link to chromium I will try to ask for advice / confirmation there.
from three.js.
Related Issues (20)
- Please add back unit tests for addons HOT 7
- No Pointer Lock HOT 2
- Editor keeps rendering video on background even if users had stopped it HOT 4
- WARN THREE.WebGLRenderer: Image in DataTexture is too big (8192x1024). HOT 1
- copyTextureToTexture using WebGL1 function signature HOT 2
- Chrome Text Distortion When New Elements Are Added HOT 13
- Not displayed after importing 3MF and AMF files HOT 1
- OrbitControls 's change Event dispatch wrong when dampling is true HOT 1
- Documentation for TeapotGeometry (add-on) HOT 2
- Editor: Missing `User Data` input in Geometry tab HOT 1
- readRenderTargetPixels() works for WebGLRenderTarget but is all 0 for WebGL3DRenderTarget HOT 21
- Please allow FBXLoader to use every non native texture that ThreeJS can load HOT 1
- It seems like there is an issue with outputNode in connection with depthNode HOT 1
- Rendering a scene including points with an override material causes inconsistent behavior HOT 2
- Target is not updated when panning the camera in ArcballControls HOT 1
- [WebGPU] Control Access Barriers HOT 1
- Suggestion of docs improvement. HOT 1
- ShaderMaterial for Hand breaks their motion tracking in WebXR (Quest3 tested) HOT 2
- [TSL] Invalid output, missing conversion of type in some cases HOT 1
- [TSL] Adding .label to a uniform prevent it from being updated through .value =
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from three.js.