question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebGLBindingStates: Memory leak in needsUpdate().

See original GitHub issue

Describe the bug

There’s a very interesting memory leak introduced at some point

https://github.com/mrdoob/three.js/blob/43c3d98af25afbbd1baa9d945cb8594e558422f7/src/renderers/webgl/WebGLBindingStates.js#L172

What it does is crease 2 arrays every time the method is called (via Object.keys) just to compare their lengths. In my basic performance tests - I saw this little gem contribute to about 35% of GC overhead in my application or around 1kb per frame.

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://threejs.org/examples/#webgl_instancing_performance
  2. Click on the mouse
  3. See error in usage of allocations, after you run an allocation recording

Code

if ( Object.keys( cachedAttributes ).length !== Object.keys( geometryAttributes ).length ) return true;

Live example

Expected behavior

No allocations expected to be performed

Screenshots

If applicable, add screenshots to help explain your problem (drag and drop the image). image

Platform:

  • Device: [Desktop]
  • OS: [Windows]
  • Browser: [Chrome, Firefox]
  • Three.js version: [r??? - yes, 122]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
takahiroxcommented, Nov 6, 2020

Hi @Usnul, thanks for the report. I think this report is meaningful. Would you please update the issue comment with the bug report template because I don’t want this report to be deleted?

In my basic performance tests - I saw this little gem contribute to about 35% of GC overhead in my application or around 1kb per frame.

I came up with a solution. Would you please share the test with me to check if it works? Or could you test in your side for me if I make a PR?

1reaction
makccommented, Nov 6, 2020

@Mugen87 isnt it just to quit early before checking values

Read more comments on GitHub >

github_iconTop Results From Across the Web

Three.js memory leak - Stack Overflow
The dynamic memory allocation/deallocation example is leaking not only @ the example link: ... needsUpdate = true; var material = new THREE.
Read more >
Memory leak issue in chrome - Questions - three.js forum
I need to create a THREE.Group containing ~600 object. The objects inside this group need to be recreated with a high frequency.
Read more >
Understanding Memory Leaks in Nodejs | by Chidume Nnamdi
In this post, we will learn, using examples, about memory leaks in Nodejs and how we can solve them. In our effort to...
Read more >
JScript Memory Leaks - Douglas Crockford
In it, the purge function is called just before deleting DOM elements. Note that handlers that were added with attachEvent() will not be...
Read more >
A tale of three(.js) snapshots and Angular 2 or how memory ...
A tale of three(.js) snapshots and Angular 2 or how memory leaks! ... destroyed through the use of the ngOnDestroy() hook that it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found