# Destroy throws render error

**URL:** <https://community.cesium.com/t/destroy-throws-render-error/12184>\
**Category:** CesiumJS\
**Created:** [February 1, 2021, 6:20am UTC](https://community.cesium.com/t/destroy-throws-render-error/12184 "2021-02-01T06:20:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shlgilad](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/shlgilad/32/3476_2.png) [@shlgilad](https://community.cesium.com/u/shlgilad)\
**Post date:** [February 1, 2021, 6:20am UTC](https://community.cesium.com/t/destroy-throws-render-error/12184/1 "2021-02-01T06:20:18Z")

</div>

Hello. I built an application using Resium which uses several models, tilesets, polyline and polygons.  
All are components under the Viewer component. What is the right way to exit from the whole Cesium component?  
When i try to destroy the models i get this error:

An error occurred while rendering. Rendering has stopped.  
DeveloperError: This object was destroyed, i.e., destroy() was called.  
Error  
at new DeveloperError ([http://localhost:3000/cesium/Cesium.js:82:23](http://localhost:3000/cesium/Cesium.js:82:23))  
at Model.throwOnDestroyed ([http://localhost:3000/cesium/Cesium.js:29066:23](http://localhost:3000/cesium/Cesium.js:29066:23))  
at PrimitiveCollection.update ([http://localhost:3000/cesium/Cesium.js:131116:31](http://localhost:3000/cesium/Cesium.js:131116:31))  
at updateAndRenderPrimitives ([http://localhost:3000/cesium/Cesium.js:237416:31](http://localhost:3000/cesium/Cesium.js:237416:31))  
at executeCommandsInViewport ([http://localhost:3000/cesium/Cesium.js:237250:17](http://localhost:3000/cesium/Cesium.js:237250:17))  
at Scene.updateAndExecuteCommands ([http://localhost:3000/cesium/Cesium.js:237058:17](http://localhost:3000/cesium/Cesium.js:237058:17))  
at render ([http://localhost:3000/cesium/Cesium.js:237721:19](http://localhost:3000/cesium/Cesium.js:237721:19))  
at tryAndCatchError ([http://localhost:3000/cesium/Cesium.js:237740:17](http://localhost:3000/cesium/Cesium.js:237740:17))  
at Scene.render ([http://localhost:3000/cesium/Cesium.js:237815:17](http://localhost:3000/cesium/Cesium.js:237815:17))  
at CesiumWidget.render ([http://localhost:3000/cesium/Cesium.js:250280:29](http://localhost:3000/cesium/Cesium.js:250280:29))

Thank you very much

---

<div class="post-metadata">

**Author:** ![anneg](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/anneg/32/11217_2.png) [@anneg](https://community.cesium.com/u/anneg)\
**Post date:** [January 16, 2024, 3:19pm UTC](https://community.cesium.com/t/destroy-throws-render-error/12184/2 "2024-01-16T15:19:32Z")

</div>

Not sure if this is still relevant, but for anyone who lands here due to searching for that specific error:

[`PrimitiveCollection.remove()`](https://cesium.com/learn/cesiumjs/ref-doc/PrimitiveCollection.html#remove) already calls [`Primitive.destroy()`](https://cesium.com/learn/cesiumjs/ref-doc/Primitive.html#destroy). Calling `destroy()` again results in that error.

This behaviour can be toggled by setting [`destroyPrimitives`](https://cesium.com/learn/cesiumjs/ref-doc/PrimitiveCollection.html#destroyPrimitives) to true or false.
