omrips / viewstl

Viewstl Javascript plugin - STL/OBJ 3D files Viewer by viewstl.com
MIT License
186 stars 46 forks source link

Possible memory leak #11

Closed antho1404 closed 3 years ago

antho1404 commented 3 years ago

After integrating the library in a vue website, I realized that after only a few viewer's creations (while navigating between pages), the page crashed because of a lack of memory. The memory of the page reached a maximum of 4GB.

For some reason, this leak is amplified in my application, and my memory increased by about 1GB for each refresh, making navigation between projects limited to 4 projects.

While my application certainly amplifies the memory increase, I tried on a basic standalone page to reproduce the leak.

You can find in the attachment a minimal version to reproduce the leak.

The application has a button to reload the StlViewer. Every time the viewer is re-loaded, the memory increased by about 80MB (with the file attached of 35MB).

You can visualize the memory consumption directly from the page or monitor it with the "performance monitor" on chrome.

test.zip

omrips commented 3 years ago

There is no 'dispose' method for the plugin at the moment, so it will leave trace in memory if you'll do stl_viewer=null (browser's GC won't be able to clean it all).

BUT, the 'clean' method should at least remove the data of the currently displayed 3D models ... I guess something is wrong there. I'll take a look and will update you.

Thanks for the heads up!

omrips commented 3 years ago

Indeed a memory leak!!! one ref. caused this :/

Will be fixed next version, meanwhile you can download a draft version from here: https://www.viewstl.com/new_viewstl/plugin_files/stl_viewer.js

I also create 'dispose' method, in order to get rid of every possible ref. inside the stl_viewer object. (take a look: http://www.viewstl.com/test/index.html )

antho1404 commented 3 years ago

That seems to work great. Well done 👍

Do you have any idea when would be the next release?

omrips commented 3 years ago

Hopefully next weekend

antho1404 commented 3 years ago

Awesome :)