# How to delete a \`vtkUnstructuredGrid\`

**URL:** https://discourse.paraview.org/t/how-to-delete-a-vtkunstructuredgrid/13398
**Category:** ParaView Support
**Created:** [November 30, 2023, 11:02am UTC](https://discourse.paraview.org/t/how-to-delete-a-vtkunstructuredgrid/13398 "2023-11-30T11:02:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Massimiliano\_Leoni](https://discourse.paraview.org/user_avatar/discourse.paraview.org/massimiliano_leoni/32/376_2.png) [@Massimiliano\_Leoni](https://discourse.paraview.org/u/Massimiliano_Leoni)
#### Post date: [November 30, 2023, 11:02am UTC](https://discourse.paraview.org/t/how-to-delete-a-vtkunstructuredgrid/13398/1 "2023-11-30T11:02:15Z")

</div>

Hello, I hope this question wasn’t asked too many times before as I expect many to have had this issue [still, searching didn’t yield anything useful].

I have a Python script [not written by me] that looks like

```
for i in range(many):
    temperature = XMLUnstructuredGridReader(FileName=something[i])
    temperature.PointArrayStatus = ['Temperature']
    Data = paraview.servermanager.Fetch(temperature)
    # do stuff
    Delete(temperature)

```

and I think I detected, via debugging, that `Data` is leaking.  
I tried to call `Delete(Data)` but I get a complaint that `Data` is the wrong type to pass to `Delete`.  
I tried to call `Data.UnRegister` but it needs an argument. Passing `None` doesn’t release the memory; I don’t know what else to pass.

I’m sure it’s something silly but I can’t figure it out. How do I deallocate `Data`?  
Any help is very appreciated!

Massimiliano

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.paraview.org/user_avatar/discourse.paraview.org/christos_tsolakis/32/4450_2.png) [@Christos\_Tsolakis](https://discourse.paraview.org/u/Christos_Tsolakis)
#### Post date: [November 30, 2023, 2:07pm UTC](https://discourse.paraview.org/t/how-to-delete-a-vtkunstructuredgrid/13398/2 "2023-11-30T14:07:04Z")

</div>

Since `Data` is reference-counted you can set it to `None` and python will release the memory associated with this object or call `Data.UnRegister(None)`.

---

<div class="post-metadata">

### Author: ![Massimiliano\_Leoni](https://discourse.paraview.org/user_avatar/discourse.paraview.org/massimiliano_leoni/32/376_2.png) [@Massimiliano\_Leoni](https://discourse.paraview.org/u/Massimiliano_Leoni)
#### Post date: [November 30, 2023, 2:43pm UTC](https://discourse.paraview.org/t/how-to-delete-a-vtkunstructuredgrid/13398/3 "2023-11-30T14:43:33Z")

</div>

As I said in my original message, neither of these two options works. 🤔

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.paraview.org/user_avatar/discourse.paraview.org/christos_tsolakis/32/4450_2.png) [@Christos\_Tsolakis](https://discourse.paraview.org/u/Christos_Tsolakis)
#### Post date: [November 30, 2023, 2:49pm UTC](https://discourse.paraview.org/t/how-to-delete-a-vtkunstructuredgrid/13398/4 "2023-11-30T14:49:34Z")

</div>

What if you run the garbage collector after setting the object to `None` ?

```python
import gc
gc.collect()

```

---

<div class="post-metadata">

### Author: ![Massimiliano\_Leoni](https://discourse.paraview.org/user_avatar/discourse.paraview.org/massimiliano_leoni/32/376_2.png) [@Massimiliano\_Leoni](https://discourse.paraview.org/u/Massimiliano_Leoni)
#### Post date: [November 30, 2023, 2:55pm UTC](https://discourse.paraview.org/t/how-to-delete-a-vtkunstructuredgrid/13398/5 "2023-11-30T14:55:57Z")

</div>

Same thing 😢

I think doing nothing, `del Data` and forcing garbage collection is the same thing.
