Yes, this seems to work very well! Thank you so much for the help!<div><br></div><div>Cheers,</div><div>Karl<br><br><div class="gmail_quote">On Fri, Feb 11, 2011 at 12:55 PM, Berk Geveci <span dir="ltr">&lt;<a href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Actually, it may be leaking display properties. Try:<br>
<br>
Delete(dp)<br>
<br>
The best thing to do in scripts is to be consistent in whether you use<br>
the simple or the servermanager to create objects. If you use the<br>
simple module, make sure you call Delete(). If you are using<br>
servermanager, you don&#39;t have to call Delete().<br>
<br>
I think that this goes for the display properties. As soon as you call<br>
Show() or GetDisplayProperties(), the simple module will create a<br>
representation object and register it with what is called the proxy<br>
manager. By the way, calling Initialize() on the view is a bad idea.<br>
It doesn&#39;t do what you think it does. Do this:<br>
<br>
for infile in glob.glob( os.path.join(path, &#39;*.vtk&#39;) ):<br>
     print &quot;Input file: &quot; + infile<br>
<br>
     # read the vtk file<br>
     reader = LegacyVTKReader(FileNames=infile)<br>
     Show(reader)<br>
     dp = GetDisplayProperties(reader)<br>
<br>
     # Create LUT<br>
     dp.LookupTable = MakeBlueToRedLT(0, 1)<br>
<br>
     # Set array to color by the model<br>
     dp.ColorAttributeType = &#39;POINT_DATA&#39;<br>
     dp.ColorArrayName = &#39;Model&#39;<br>
     servermanager.createModule(&quot;piecewise_functions&quot;, servermanager.rendering)<br>
<br>
     # Setup opacity function<br>
     opacity_func = servermanager.rendering.PiecewiseFunction()<br>
     opacity_func.Points = [0, 0, 1, 0.5]<br>
     dp.ScalarOpacityFunction = opacity_func<br>
     dp.Representation = &#39;Volume&#39;<br>
<br>
     view0 = GetActiveView()<br>
     view0.Background =[0.57,0.61,0.77]<br>
<br>
     # Set the camera and view options, etc<br>
     view0.OrientationAxesVisibility=1<br>
     view0.CenterAxesVisibility=1<br>
     view0.ViewSize=[632,632]<br>
     view0.CameraPosition = [430,420,310]<br>
     view0.CameraFocalPoint = [-135,-125,-20]<br>
     view0.CameraViewUp = [-0.26,-0.29,0.92]<br>
<br>
     # Render<br>
     Render()<br>
<br>
     # write out the png file<br>
     new=infile.replace(&#39;.vtk&#39;,&#39;.png&#39;)  # use orig filename for png filename<br>
     print &quot;Output file: &quot; + new<br>
     WriteImage(new, view0)<br>
<br>
     view0.Representations = []<br>
     Delete(dp)<br>
     Delete(reader)<br>
<div><div></div><div class="h5"><br>
<br>
On Fri, Feb 11, 2011 at 12:05 PM, Karl Battams &lt;<a href="mailto:karlbattams@gmail.com">karlbattams@gmail.com</a>&gt; wrote:<br>
&gt; Pat,<br>
&gt; Ah! That makes sense now I think about it.<br>
&gt; So I put the call at the end of my routine, and it pukes after the first<br>
&gt; file:<br>
&gt;<br>
&gt; Traceback (most recent call last):<br>
&gt;   File &quot;script.py&quot;, line 52, in &lt;module&gt;<br>
&gt;     Delete(reader)<br>
&gt;   File &quot;/usr/local/lib/paraview-3.11/paraview/simple.py&quot;, line 367, in<br>
&gt; Delete<br>
&gt;     servermanager.UnRegister(proxy)<br>
&gt;   File &quot;/usr/local/lib/paraview-3.11/paraview/servermanager.py&quot;, line 2674,<br>
&gt; in UnRegister<br>
&gt;     raise RuntimeError, &quot;UnRegistration error.&quot;<br>
&gt; RuntimeError: UnRegistration error.<br>
&gt;<br>
&gt; Thanks again,<br>
&gt; ~~Karl<br>
&gt;<br>
&gt; On Fri, Feb 11, 2011 at 11:47 AM, pat marion &lt;<a href="mailto:pat.marion@kitware.com">pat.marion@kitware.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; Your loop is leaking readers.   At the end of your loop, call<br>
&gt;&gt; Delete(reader).  The Delete() function is analogous to selecting an object<br>
&gt;&gt; in the paraview gui and pressing the delete key.  You&#39;ll still leak some<br>
&gt;&gt; objects, there are more thorough ways you cleanup, but deleting the reader<br>
&gt;&gt; make take care of the bulk of it.  You can remove the Initialize() calls.<br>
&gt;&gt;<br>
&gt;&gt; Pat<br>
&gt;&gt;<br>
&gt;&gt; On Fri, Feb 11, 2011 at 7:31 AM, Karl Battams &lt;<a href="mailto:karlbattams@gmail.com">karlbattams@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi Pat,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Yes -- I should have gone with my first suspicion. It is indeed a memory<br>
&gt;&gt;&gt; leak. I&#39;m obviously not cleaning stuff up properly... which doesn&#39;t surprise<br>
&gt;&gt;&gt; me because my script really is kind of a hack... I have attached it.<br>
&gt;&gt;&gt; Basically it reads a directory of vtk files, loops over each, volume-renders<br>
&gt;&gt;&gt; them with a fixed set of camera positions, and then saves a png.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; One issue I was having was getting paraview to &quot;forget&quot; about the<br>
&gt;&gt;&gt; previous vtk file. It was rendering each new image over the top of the<br>
&gt;&gt;&gt; previous one. I fixed that by using Initialize( ) on the different views at<br>
&gt;&gt;&gt; the end of the loop, but that is perhaps (probably!) not the right way to do<br>
&gt;&gt;&gt; it.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Many thanks for your help!<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Regards,<br>
&gt;&gt;&gt; Karl<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Thu, Feb 10, 2011 at 3:08 PM, pat marion &lt;<a href="mailto:pat.marion@kitware.com">pat.marion@kitware.com</a>&gt;<br>
&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hi Karl,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; It sounds like a memory leak problem.  Have you tried opening the System<br>
&gt;&gt;&gt;&gt; Monitor in ubuntu and watching the memory usage of pvserver as you run your<br>
&gt;&gt;&gt;&gt; script?  Can you post your script so we can take a look at it, maybe you<br>
&gt;&gt;&gt;&gt; aren&#39;t cleaning up after you process each file?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; You can pass --cslog=log.txt to pvserver.  This records very low level<br>
&gt;&gt;&gt;&gt; log information, it captures every message sent to the server.  Problem is<br>
&gt;&gt;&gt;&gt; that it does not work very well for a parallel server, all processes all<br>
&gt;&gt;&gt;&gt; write to the same file.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; pvserver exits when the client disconnects and there is no keep-alive<br>
&gt;&gt;&gt;&gt; flag.  Try running pvserver in a bash loop, or starting it from your python<br>
&gt;&gt;&gt;&gt; script.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Pat<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On Thu, Feb 10, 2011 at 1:46 PM, Karl Battams &lt;<a href="mailto:karlbattams@gmail.com">karlbattams@gmail.com</a>&gt;<br>
&gt;&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I&#39;m pretty new to paraview so could be doing fundamentally wrong here,<br>
&gt;&gt;&gt;&gt;&gt; but here&#39;s my issue...<br>
&gt;&gt;&gt;&gt;&gt; I have paraview 3.10 compiled/installed from source on Ubuntu 10. I&#39;m<br>
&gt;&gt;&gt;&gt;&gt; using a python script to connect to pvserver, iterate over a bunch of vtk<br>
&gt;&gt;&gt;&gt;&gt; files, do some stuff, and saving the output as a png. I&#39;m running the python<br>
&gt;&gt;&gt;&gt;&gt; script and the pvserver on the same (8-core) machine.<br>
&gt;&gt;&gt;&gt;&gt; So I start pvserver with (e.g.) mpirun -np 6 pvserver and it sits<br>
&gt;&gt;&gt;&gt;&gt; happily listening for a client. In another terminal, I run my python script<br>
&gt;&gt;&gt;&gt;&gt; which connects (successfully) to pvserver, and starts running through the<br>
&gt;&gt;&gt;&gt;&gt; files exactly as I ask it to. So far so good.<br>
&gt;&gt;&gt;&gt;&gt; Problem is, after a random length of time, and/or number of files, the<br>
&gt;&gt;&gt;&gt;&gt; pvserver abruptly dies and so the whole python script obviously dies with<br>
&gt;&gt;&gt;&gt;&gt; it. The pvserver gives no error message... just dies. If I just run the<br>
&gt;&gt;&gt;&gt;&gt; script for one file (or even a few of them), it runs without an issue.<br>
&gt;&gt;&gt;&gt;&gt; What I have noticed is that the less processors I use, the more files<br>
&gt;&gt;&gt;&gt;&gt; my script will process before pvserver dies. If I use pvserver by itself<br>
&gt;&gt;&gt;&gt;&gt; (i.e. one processor) it will do about 120-or-so files. If I use four<br>
&gt;&gt;&gt;&gt;&gt; processors, it&#39;ll only go through 30-or-so before one of them throws a kill<br>
&gt;&gt;&gt;&gt;&gt; signal and takes the whole thing down. It is not a particular file that does<br>
&gt;&gt;&gt;&gt;&gt; it, nor is it at a particular point in the processing script. The length of<br>
&gt;&gt;&gt;&gt;&gt; time and number of files processed is also not fixed. (It&#39;s almost like it&#39;s<br>
&gt;&gt;&gt;&gt;&gt; a memory leak issue..??)<br>
&gt;&gt;&gt;&gt;&gt; So... questions:<br>
&gt;&gt;&gt;&gt;&gt; 1) Am I being inefficient/stupid by using pvserver + python script to<br>
&gt;&gt;&gt;&gt;&gt; do this batch processing? If so, what&#39;s the recommended practice?<br>
&gt;&gt;&gt;&gt;&gt; 2) My script only does one server connect (via Connect(&#39;localhost&#39;) )<br>
&gt;&gt;&gt;&gt;&gt; and then loops over the files. Should I do a new server connect for each<br>
&gt;&gt;&gt;&gt;&gt; file instead?<br>
&gt;&gt;&gt;&gt;&gt; 3) Assuming yes to question 2, how do I cleanly disconnect from<br>
&gt;&gt;&gt;&gt;&gt; pvserver without killing the server altogether (see below)?<br>
&gt;&gt;&gt;&gt;&gt; 4) If I run a single instance of file processing (i.e. one file) the<br>
&gt;&gt;&gt;&gt;&gt; script runs fine... but when it&#39;s done, the pvserver disconnects the client<br>
&gt;&gt;&gt;&gt;&gt; and dies. Is that normal? Is there a &#39;keep-alive&#39; flag for pvserver? Why<br>
&gt;&gt;&gt;&gt;&gt; does dropping the connection kill the server?<br>
&gt;&gt;&gt;&gt;&gt; 5) Does pvserver leave any logs anywhere? Anyway I can trace what&#39;s<br>
&gt;&gt;&gt;&gt;&gt; causing the kill signal?<br>
&gt;&gt;&gt;&gt;&gt; I just can&#39;t shake the feeling that the pvserver process should be a<br>
&gt;&gt;&gt;&gt;&gt; lot more robust than what I&#39;m seeing.<br>
&gt;&gt;&gt;&gt;&gt; Many thanks for any help!<br>
&gt;&gt;&gt;&gt;&gt; Karl<br>
&gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt;&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Visit other Kitware open-source projects at<br>
&gt;&gt;&gt;&gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Please keep messages on-topic and check the ParaView Wiki at:<br>
&gt;&gt;&gt;&gt;&gt; <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt;&gt;&gt;&gt; <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the ParaView Wiki at:<br>
&gt; <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>