I wrote a script for pvpython
to convert a batch of vtk-Files to binary vtu-Files.
import sys
from paraview.simple import *
print 'Number of files to be converted:', len(sys.argv) - 1
for x in range(1, len(sys.argv)):
inputFile = str(sys.argv[x])
outputFile = inputFile[:-1] + 'u'
print x,': Converting ', inputFile, ' -> ', outputFile
r = LegacyVTKReader( FileNames= inputFile )
w = XMLUnstructuredGridWriter()
w.FileName = outputFile
w.UpdatePipeline()
I run it like this inside a folder with around 2000 vtk-Files:
pvpython conversion.py *.vtk
After some time, my systems runs out of memory.
Where does this leak come from?
I'm still new to python. Do I have to to delete the variables manually at the end of each loop?
Try using a Delete
call. e.g.
...
w.UpdatePipeline()
Delete(w)
Delete(r)