I had previously opened an issue here (Paraview ResetSession causing crashes - #3 by ihelt) about ResetSession() causing a crash which had a similar minimally working example (in case this looks familiar), but the code below creates a new layout, which was a remedy suggested in issue 22831 (https://gitlab.kitware.com/paraview/paraview/-/issues/22831).
from paraview.simple import *
import os
class pv:
def __init__(self,casename):
print('Initializing...')
self.enReader = EnSightReader(registrationName='case1', CaseFileName=casename)
# Create layout: Remedy to ResetSession crashing (Paraview issue 22831)
layout = CreateLayout()
self.renderView = GetActiveViewOrCreate('RenderView')
AssignViewToLayout(view=self.renderView, layout=layout)
def __del__(self):
print('deleting...')
Delete(self.enReader)
ResetSession()
def makeBlock(self):
print('Making block...')
self.extractBlock = ExtractBlock(registrationName='block', Input=self.enReader)
self.extractBlockDisplay = Show(self.extractBlock, self.renderView, 'UnstructuredGridRepresentation')
self.extractBlock.Selectors = ['booster']
def makePicture(self,picName):
pic_path = './'+picName+'.png'
print('Saving '+picName+'...')
layout = GetLayout()
layout.SetSize(1400,200)
if os.path.exists(pic_path):
os.remove(pic_path)
SaveScreenshot(pic_path, self.renderView, ImageResolution=[1400, 200], OverrideColorPalette='BlackBackground')
def main():
# NOTE: "error: exception occurred: Subprocess killed" is a result of all memory being used by CPU
casename1 = /path/to/file.case'
i = 1
while i < 10:
print('-----------------------------------')
pvi = pv(casename1)
pvi.makeBlock()
pvi.makePicture('pic{0:d}'.format(i))
pvi.__del__()
del pvi
print('pv{0:d} done'.format(i))
i = i+1
print('done')
if __name__ == '__main__':
main()
Executing this code gives me the following output:
user:> pvpython --mesa replicateCrash.py
-----------------------------------
Initializing...
VisRTX 0.1.6, using devices:
0: Quadro P2000 (Total: 5.3 GB, Available: 5.1 GB)
Making block...
Saving pic1...
deleting...
deleting...
pv1 done
-----------------------------------
Initializing...
Making block...
Saving pic2...
deleting...
deleting...
pv2 done
-----------------------------------
Initializing...
Making block...
Saving pic3...
deleting...
deleting...
pv3 done
-----------------------------------
Initializing...
Making block...
error: exception occurred: Subprocess killed
where the crash coincides with my memory usage being completely full.