spite / THREE.MeshLine

Mesh replacement for THREE.Line
MIT License
2.14k stars 381 forks source link

Memory leak - maybe? #11

Open supermoos opened 8 years ago

supermoos commented 8 years ago

First of all, great job, it's a lovely addition to Three.js!

I'm not completely sure, but I think there may be a memory leak somewhere, I tested your spinner demo (basically holding down the mouse and releasing again after a few minutes), in Chrome the memory consumption just goes up and up, and never down again. On another project I'm working on this get's much more apparent since I'm updating the THREE.MeshLine geometry on every frame with the THREE.MeshLine.setGeometry() function.

Please see the attached screenshot for a memory profile, looks like it may have something to do with the WebGLBuffer objects?

Correct me if I'm wrong, just wanted to let you know as I guess you can figure whether there's any hold in this theory pretty fast :-)

screen shot 2016-01-04 at 16 15 02

spite commented 8 years ago

It's very possible there's a memory leak. Reusing properly the buffers is in the TODO list. I have to take a closer look at it, and how to dispose of buffers in threejs

supermoos commented 8 years ago

Okay, sure thing :-)

jeremyabel commented 8 years ago

fixed in #15

qvantor commented 8 years ago

This fix is not working

ihor-zhakun commented 8 years ago

it doesn't work if count of points in position array changed

Jared-Sprague commented 7 years ago

Found a memory leak and fixed it in https://github.com/spite/THREE.MeshLine/pull/25/commits/f6c9ba00a1f59d299d12506b9365a1f87525fc78

Basically the this.counters array was getting pushed values every time setGeometry() is called but was never cleared, so it would just keep growing.

Fixed by this.counters = [] at the begining of setGeometry()