# Correctly remove mesh from scene and dispose material and geometry

**URL:** https://discourse.threejs.org/t/correctly-remove-mesh-from-scene-and-dispose-material-and-geometry/5448
**Category:** Questions
**Tags:** memory-leak
**Created:** [December 21, 2018, 7:21am UTC](https://discourse.threejs.org/t/correctly-remove-mesh-from-scene-and-dispose-material-and-geometry/5448 "2018-12-21T07:21:18Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [December 21, 2018, 9:03am UTC](https://discourse.threejs.org/t/correctly-remove-mesh-from-scene-and-dispose-material-and-geometry/5448/2 "2018-12-21T09:03:31Z")

</div>

> [@MichaelJendryke](#):
>
> scene.getObjectByProperty( ‘uuid’, i )

Execute this code once and not three times in a row. This will save some overhead. Do it like so:

```js
const object = scene.getObjectByProperty( 'uuid', i );

object.geometry.dispose();
object.material.dispose();
scene.remove( object );

```

The order of the last three statements does actually not matter.

> [@MichaelJendryke](#):
>
> I came up with the below function, but disposing geometry and material like this does not work, i.e. they are still in memory.

Does the memory leak disappear if you execute the following code after removing the cells?

```js
renderer.renderLists.dispose();

```

---

_[View the full topic](https://discourse.threejs.org/t/correctly-remove-mesh-from-scene-and-dispose-material-and-geometry/5448)._
