# About Entity.destroy()

**URL:** <https://forum.playcanvas.com/t/about-entity-destroy/2536>\
**Category:** Help & Support\
**Created:** [September 28, 2016, 7:13am UTC](https://forum.playcanvas.com/t/about-entity-destroy/2536 "2016-09-28T07:13:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![WingUNO](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/winguno/32/1678_2.png) [@WingUNO](https://forum.playcanvas.com/u/WingUNO)\
**Post date:** [September 28, 2016, 7:13am UTC](https://forum.playcanvas.com/t/about-entity-destroy/2536/1 "2016-09-28T07:13:00Z")

</div>

Hi, this is my code about _initRaod_ and _resetRoad_ :

![](https://forum-files-playcanvas-com.s3-eu-west-1.amazonaws.com/original/2X/a/ab01de452be13d3dcaca55092b25ed13acc611b3.png)

When the game start, the _initRoad_ will be called and 10 roads cloned from _Road01_ are pushed into _roadEntitiesArray_. When the game reset, the _reset_ function will be fired and all roadEntities in _roadEntitiesArray_ will be destroyed one by one and call the _initRoad_ again to reset roads.

But the first time I reset the game, the mesh Instances will increase from 24 to 40. And after that, I reset the game again and again, the mesh Instances will no more increase and just keep 40. What’s going on ?

Thank you in advance !

![](https://forum-files-playcanvas-com.s3-eu-west-1.amazonaws.com/original/2X/2/241fe61697f8ede9596579700b22db602bbf0d11.png) ![](https://forum-files-playcanvas-com.s3-eu-west-1.amazonaws.com/original/2X/5/52a3d64dd00510988eec7bec9d1922346c88634d.png)

---

<div class="post-metadata">

**Author:** ![WingUNO](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/winguno/32/1678_2.png) [@WingUNO](https://forum.playcanvas.com/u/WingUNO)\
**Post date:** [September 29, 2016, 5:57am UTC](https://forum.playcanvas.com/t/about-entity-destroy/2536/2 "2016-09-29T05:57:50Z")

</div>

Hello ? Does my description not detile enough ? Ah, you could have a look on my [project](https://playcanvas.com/project/425272/overview/just-rolling).

There are two functions which I have commented in Road.js. Although I have used another way to fix this problem, I want to figure out why.

Thank you so much.

---

<div class="post-metadata">

**Author:** ![dave](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/dave/32/4558_2.png) [@dave](https://forum.playcanvas.com/u/dave)\
**Post date:** [September 29, 2016, 9:30am UTC](https://forum.playcanvas.com/t/about-entity-destroy/2536/3 "2016-09-29T09:30:19Z")

</div>

I just ran the game and the number of meshinstances and the draw calls seems to be pretty stable even after restarting several times.

Is this still a problem? If not how did you fix it?

Thanks

---

<div class="post-metadata">

**Author:** ![WingUNO](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/winguno/32/1678_2.png) [@WingUNO](https://forum.playcanvas.com/u/WingUNO)\
**Post date:** [September 29, 2016, 9:44am UTC](https://forum.playcanvas.com/t/about-entity-destroy/2536/4 "2016-09-29T09:44:38Z")

</div>

Hi, dave. At the first time, I used following reset function which I have commented to reset the roads :

![](https://forum-files-playcanvas-com.s3-eu-west-1.amazonaws.com/original/2X/f/fb850663a8082aa5ddc005d4fca1baacda3d8a75.png)

Afterwards, I use this function:

![](https://forum-files-playcanvas-com.s3-eu-west-1.amazonaws.com/original/2X/5/58defbb30ab0cdc49cada662564100e1fd32a349.png)

I just avoid destroying and re-cloneing the roads. But normally, destroying and re-cloneing the roads should be OK. Also, I checked out the ![](https://forum-files-playcanvas-com.s3-eu-west-1.amazonaws.com/original/2X/0/02327d87c74312cb147522de458b27935a56ccfe.png) and it was cleared as well. However, the number of mesh instance still increased at the first time when reseting the roads.
