[Paraview] Python Scripting Memory Overload

Pat Marion pat.marion at kitware.com
Thu Dec 20 02:50:28 EST 2012


I think you need to replace "del writer" with "Delete(writer)".

ParaView has a proxy manager that keeps all proxies.  Proxies will not be
deleted when the python reference is deleted, you must explicitly call
paraview.simple.Delete().  The return value of CreateWriter is a proxy, so
it must be Delete()'d.

+1 for Dave's suggestion, build the pipeline and writer before the loop.

Pat

On Thu, Dec 20, 2012 at 7:43 AM, Andy Bauer <andy.bauer at kitware.com> wrote:

> I believe the filter won't get deleted until after the proxy goes out of
> scope. If I'm right, you need to call Delete() on it and then have the
> variable that's holding the proxy either go out of scope or set to
> something else.
>
> Andy
>
>
> On Wed, Dec 19, 2012 at 4:36 PM, David E DeMarle <dave.demarle at kitware.com
> > wrote:
>
>> Not sure why it isn't garbage collecting for you, but you might try
>> moving the entire pipeline setup out of the loop and then inside the
>> loop just call the two set filenames to modify the existing pipeline
>> before calling Write().
>>
>> David E DeMarle
>> Kitware, Inc.
>> R&D Engineer
>> 21 Corporate Drive
>> Clifton Park, NY 12065-8662
>> Phone: 518-881-4909
>>
>>
>> On Wed, Dec 19, 2012 at 4:25 PM, Sebastian <sebastiansturm at web.de> wrote:
>> > Hello Karl,
>> >
>> > thank you for your message. I am using Paraview 3.14.1 (64bit).
>> >
>> > This is what my script looks like:
>> >
>> > # SETTINGS
>> > directory_pvtu    = '/scratch/mesh3mm_SEM/'
>> > directory_csv     = '/scratch/mesh3mm_SEM/Z085_velocity_data/'
>> > file_number_start = 373527
>> > file_number_end   = 640332
>> > file_interval     = 693
>> > file_name_pvtu    = 'mesh3mm_SEM###file_number###.pvtu'
>> > file_name_csv     = 'mesh3mm_SEM###file_number###.csv'
>> >
>> > print 'Script started!'
>> >
>> > try: paraview.simple
>> > except: from paraview.simple import *
>> >
>> > while file_number_start <= file_number_end :
>> >
>> >   current_file_name_pvtu = file_name_pvtu.replace('###file_number###',
>> > str(file_number_start))
>> >   current_file = XMLPartitionedUnstructuredGridReader(
>> FileName=[directory_pvtu
>> > + current_file_name_pvtu] )
>> >
>> >   current_file.PointArrayStatus = ['Velocity']
>> >
>> >   SetActiveSource(current_file)
>> >
>> >   Slice1 = Slice( SliceType = 'Plane' )
>> >   Slice1.SliceOffsetValues = [0.0]
>> >   Slice1.SliceType.Origin = [0.0, 0.0, 0.136711]
>> >   Slice1.SliceType.Normal = [0.0, 0.0, 1.0]
>> >
>> >   SetActiveSource(Slice1)
>> >
>> >   Slice2 = Slice( SliceType = 'Plane' )
>> >   Slice2.SliceOffsetValues = [0.0]
>> >   Slice2.SliceType.Origin = [0.0, 0.227757, 0.0]
>> >   Slice2.SliceType.Normal = [0.0, 1.0, 0.0]
>> >
>> >   UpdatePipeline()
>> >   current_file_name_csv = file_name_csv.replace('###file_number###',
>> > str(file_number_start))
>> >   writer = CreateWriter(directory_csv + current_file_name_csv, Slice2)
>> >   writer.FieldAssociation = 'Points'
>> >   writer.UpdatePipeline()
>> >   del writer
>> >
>> >   Delete(Slice2)
>> >   Delete(Slice1)
>> >   Delete(current_file)
>> >
>> >   files_to_go = (file_number_end-file_number_start)/file_interval
>> >   if files_to_go == 1:
>> >     case_word = 'file'
>> >   else:
>> >     case_word = 'files'
>> >   print current_file_name_csv + ' created, ' + str(files_to_go) + '
>> more ' +
>> > case_word + ' to go!'
>> >
>> >   file_number_start += file_interval
>> >
>> > print 'Script finished!'
>> >
>> > Best,
>> > Sebastian
>> >
>> > _______________________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>> >
>> > Please keep messages on-topic and check the ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.paraview.org/mailman/listinfo/paraview
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.paraview.org/mailman/listinfo/paraview
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20121220/69792e9a/attachment.htm>


More information about the ParaView mailing list