<div dir="ltr"><div>I hope that some expert can offer their advice...</div><div>I'm trying to use VTK in a program that is multi-threaded at a fairly coarse level - for example it has threads doing visualisation, others saving data in the background. I understand that VTK is not thread-safe, and so I would expect to follow the usual rules for using classes that are not thread-safe: only access each object from one thread, and use mutexes to protect any global or static data. </div>
<div>But it seems that even applying these rules I am running into problems with VTK. Certainly I can't use vtkSmartPointer, because it accesses a singleton garbage collection mechanism. I tried making a mutex-protected version of vtkSmartPointer but still had memory corruptions, and I think what is happening is that inside VTK when objects are being created and destroyed, some static or singleton data is being accessed. </div>
<div>So for instance if I create two filters, each in a different thread, use them in their own threads and destroy them in their own threads, I still seem to get strange errors that I don't get in a single-threaded version of the program, presumably because the filter is creating its own temporary objects via some internal memory management system that is not thread-safe.</div>
<div>Can anyone offer any advice? Is VTK simply unusable in a multi-threaded program? Any serious application program (not research tool) is going to be multi-threaded, surely others must have addressed this issue?</div>
<div>Any help very gratefully received.</div><div>Richard</div><div><br></div><br><div dir="ltr"><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif">Richard Whitehead </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">–</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> Senior Imaging Engineer</span></p>
<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">Michelson Diagnostics Ltd</span></b></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt">
<b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">M:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> +44 (0)7905 955276 </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">T:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> +44 (0)20 8308 1695</span></p>
<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">E: </span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(0,176,240)"><a href="mailto:richard.whitehead@vivosight.com" style="color:rgb(17,85,204)" target="_blank"><span style="color:rgb(0,176,240)">richard.whitehead@vivosight.com</span></a></span><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">W:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> </span><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(0,176,240)"><a href="http://www.vivosight.com/" style="color:rgb(17,85,204)" target="_blank"><span style="color:rgb(0,176,240)">www.vivosight.com</span></a></span></p>
<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><br></p></div>
</div>