How to delete a `vtkUnstructuredGrid`

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

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!


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).

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

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

import gc

Same thing :cry:

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