Editor: Memory leak when loading 4096x4096 texture several times
See original GitHub issueDescribe the bug
I tried to edit the MaterialsVariantsShoe.glb file from the KhronosGroup git in the editor and changed the normalMap and aoMap textures several times to a 4096x4096 texture.
I could use the same texture several times and the memory starts to increase after ~9-10 times (in my tests the value of changes sometimes were even smaller). That causes the webgl context to crash after enough changes.
To Reproduce
Steps to reproduce the behavior:
- Go to ThreeJS Editor
- Import MaterialsVariantsShoe.glb
- Change material to MeshPhysicalMaterial
- Set the normalMap / aoMap >10 times to a 4096x4096 texture
- The leak begins to grow after every following change
Expected behavior
After my analysis this only happens in 64bit browsers.
The following lines of WebGLState.js
causes the increasment.
function texImage2D() {
try {
gl.texImage2D.apply( gl, arguments ); //After this function call the memory was increased highly and is only freed after closing or reloading the tab / browser.
} catch ( error ) {
console.error( 'THREE.WebGLState:', error );
}
}
Screenshots
After 30 changes with the same texture:
Browser | Taskmanager Image |
---|---|
Vivaldi 32bit | |
Vivaldi 64bit | |
Chrome 32bit | |
Chrome 64bit |
Platform:
- Device: [Desktop, Mobile]
- OS: [Windows, Android, IPadOS]
- Browser: [Chrome, Canary Chrome, Firefox, Safari, Edge, Opera, Vivaldi, Opera GX, Chrome for Android]
- Three.js version: r117 - r124
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
High Memory usage when using 4096x4096 textures (4k ...
As for the Memory, looking at the profiler, all references textures loaded, and even though for example boss is not active, all the...
Read more >Is there an editor memory leak?... - Unreal Engine Forums
Hi After working on any level in the editor for any length of time, I start to get the 'texture streaming pool over...
Read more >My Maya 2015 SP5 seems to be leaking memory (allocating 100mb ...
I'm using Maya 2015 SP5, I have a simple model that has a 4096x4096 Tiff (layer uncompressed) texture attached to a Blinn. After...
Read more >Memory leak caused loading textures, despite calling ...
Here, I've created the new texture, and loaded it using the texture class' load function. The textures render absolutely fine, but the loading...
Read more >Lifecycle of a Texture in Unreal Engine for Virtual Production
If all those polys and texture pixels add up to more memory than you have available to ... And a lot of times...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can you please call
Texture.dispose()
every time you replace an existing texture? Meaning:I’m able to crash the webgl context with this, after the memory is over ~8GB (set the normalMap ~90-100 Times in my test).