# Threejs unexplained crash "Out of Memory"

**URL:** <https://discourse.threejs.org/t/threejs-unexplained-crash-out-of-memory/39062>\
**Category:** Discussion\
**Tags:** animation\
**Created:** [June 9, 2022, 10:38am UTC](https://discourse.threejs.org/t/threejs-unexplained-crash-out-of-memory/39062 "2022-06-09T10:38:51Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![Lawrence3DPK](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lawrence3dpk/32/29184_2.png) [@Lawrence3DPK](https://discourse.threejs.org/u/Lawrence3DPK)\
**Post date:** [June 10, 2022, 7:55pm UTC](https://discourse.threejs.org/t/threejs-unexplained-crash-out-of-memory/39062/15 "2022-06-10T19:55:24Z")

</div>

If you are dynamically adding objects to your webgl environment, you also need to dynamically clear objects loaded in to memory that are no longer required, this is generally known as “garbage collection” in webgl and reffered to as `dispose()` in threejs there are many topics on here covering the disposal of no longer needed textures and geometries

> [@Memory leak issue](https://discourse.threejs.org/t/memory-leak-issue/21366/2):
>
> Try with function like this… function disposeNode (node) { if (node instanceof THREE.Mesh) { if (node.geometry) { node.geometry.dispose (); } if (node.material) { if (node.material instanceof THREE.MeshFaceMaterial) { $.each (node.material.materials, function (idx, mtrl) { if (mtrl.map) mtrl.map.dispose (); if (mtrl.lightMap) …

---

_[View the full topic](https://discourse.threejs.org/t/threejs-unexplained-crash-out-of-memory/39062)._
