<div dir="ltr">I think to have the same problem. I have a memory leak on only one
program and it contains VTK objects created in multiple threads. But I
don&#39;t know how to fix that sorry... If anyone has the solution...<br><br><div class="gmail_quote">2008/8/12 Andreas Brüning <span dir="ltr">&lt;<a href="mailto:mail-andi@web.de">mail-andi@web.de</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello everyone,<br>
<br>
regarding to my post from beginning of august:<br>
<br>
<a href="http://www.vtk.org/pipermail/vtkusers/2008-August/096309.html" target="_blank">http://www.vtk.org/pipermail/vtkusers/2008-August/096309.html</a><br>
<br>
i recompiled vtk with VTK_DEBUG_LEAKS flag in CMAKE and with use of vtkDebugLeaks i printed out the undeleted vtkobjects right before i close the program . I found out that if i create vtk objects in different threads the delete funtionality doesnŽt work anymore. When i only create vtkobjects in the mainThread they delete completely. But when i create different threads and in there new vtkObjects, dozens of vtkobjects remain in the memory.Even those i never created by myself. &nbsp;I call always the New() and Delete() methods for every vtkobject in the thread. And it happens with all kinds of vtkobjects.<br>

<br>
Here is an example of a thread-method:<br>
<br>
&nbsp;UINT __cdecl CImageVtkWnd::ResultView_2dMPR(LPVOID lpParameter )<br>
&nbsp;{<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;//managing class of the threads<br>
 &nbsp; &nbsp; &nbsp; &nbsp; CImageVtkWnd *pThis = static_cast&lt;CImageVtkWnd *&gt;(lpParameter);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;ASSERT(pThis != NULL);<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;// Create the the renderer, window and interactor objects.<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkRenderer *vtk_Renderer = vtkRenderer::New();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkWin32OpenGLRenderWindow *vtk_Win32OpenGLWindow = vtkWin32OpenGLRenderWindow::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_Win32OpenGLWindow-&gt;AddRenderer(vtk_Renderer);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;double *spacing = pThis-&gt;m_vtkvolumedata-&gt;GetSpacing();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkImageShiftScale *vtk_scale = vtkImageShiftScale::New();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_scale-&gt;SetInput(pThis-&gt;m_vtkvolumedata);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_scale-&gt;SetShift(0.5*pThis-&gt;m_dWindow - pThis-&gt;m_dLevel);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_scale-&gt;SetScale(255.0/pThis-&gt;m_dWindow);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_scale-&gt;ClampOverflowOn();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_scale-&gt;SetOutputScalarTypeToUnsignedChar();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkImageReslice *vtkImageReslicer = vtkImageReslice::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkImageReslicer-&gt;SetInput(vtk_scale-&gt;GetOutput());<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkImageReslicer-&gt;SetOutputDimensionality(2);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkImageReslicer-&gt;SetInterpolationModeToLinear();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkImageReslicer-&gt;SetOutputSpacing(spacing);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkImageReslicer-&gt;ReleaseDataFlagOn();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkImageActor *vtk_actor = vtkImageActor::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_actor-&gt;SetInput(vtkImageReslicer-&gt;GetOutput());<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkTransform *vtk_slicetransform &nbsp; &nbsp; &nbsp; &nbsp;= vtkTransform::New();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_Renderer-&gt;AddActor(vtk_actor);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_Renderer-&gt;ResetCamera();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_Renderer-&gt;GetActiveCamera()-&gt;ParallelProjectionOn();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;DWORD MultiLockObj = 0;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;CSyncObject* pWaitObjects[] = { pThis-&gt;m_hRenderEvent, pThis-&gt;m_hTerminateLoopEvent, pThis-&gt;m_hResizeEvent };<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;CMultiLock MultiLock( pWaitObjects, 3L );<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_slicetransform-&gt;Translate(pThis-&gt;m_pSliceCenter[0], pThis-&gt;m_pSliceCenter[1], pThis-&gt;m_pSliceCenter[2]);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_slicetransform-&gt;RotateZ(-pThis-&gt;m_dSliceAngle_z);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_slicetransform-&gt;RotateX(-pThis-&gt;m_dSliceAngle_x);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_slicetransform-&gt;RotateY(-pThis-&gt;m_dSliceAngle_y);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;CSize *size = new CSize(600,800);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;unsigned char *tmpdata;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;BITMAPINFO bmi={0};<br>
 &nbsp; &nbsp; &nbsp; &nbsp;bmi.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;bmi.bmiHeader.biPlanes=1;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;bmi.bmiHeader.biCompression=BI_RGB;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;bmi.bmiHeader.biBitCount=24;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;bmi.bmiHeader.biWidth=size-&gt;cx;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;bmi.bmiHeader.biHeight=size-&gt;cy;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;bmi.bmiHeader.biSizeImage=size-&gt;cx * size-&gt;cy * 24;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_Win32OpenGLWindow-&gt;SetSize(size-&gt;cx,size-&gt;cy);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_Win32OpenGLWindow-&gt;OffScreenRenderingOn();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;do<br>
 &nbsp; &nbsp; &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(MultiLockObj == (WAIT_OBJECT_0+1))<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//reslice<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(MultiLockObj == (WAIT_OBJECT_0+2))<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtk_slicetransform-&gt;Identity();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtk_slicetransform-&gt;Translate(pThis-&gt;m_pSliceCenter[0], pThis-&gt;m_pSliceCenter[1], pThis-&gt;m_pSliceCenter[2]);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtk_slicetransform-&gt;RotateZ(-pThis-&gt;m_dSliceAngle_z);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtk_slicetransform-&gt;RotateX(-pThis-&gt;m_dSliceAngle_x);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtk_slicetransform-&gt;RotateY(-pThis-&gt;m_dSliceAngle_y);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtkImageReslicer-&gt;SetResliceAxes(vtk_slicetransform-&gt;GetMatrix());<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtk_Win32OpenGLWindow-&gt;Render();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtk_Renderer-&gt;ResetCamera();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;::EnterCriticalSection(&amp;pThis-&gt;m_cs);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tmpdata = vtk_Win32OpenGLWindow-&gt;GetPixelData(0,0,size-&gt;cx-1, size-&gt;cy,1);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pThis-&gt;m_lbitmap-&gt;ConvertFromDIB(&amp;bmi,(L_UCHAR *) &nbsp; &nbsp; &nbsp; tmpdata);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pThis-&gt;m_lbitmap-&gt;SetXResolution(pThis-&gt;m_iSource_resolution);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pThis-&gt;m_lbitmap-&gt;SetYResolution(pThis-&gt;m_iSource_resolution);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pThis-&gt;m_lbitmap-&gt;CalculateXYRes();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pThis-&gt;m_lbitmap-&gt;GrayScale(pThis-&gt;m_iGrayscale);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LeaveCriticalSection(&amp;pThis-&gt;m_cs);<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;::PostMessage(pThis-&gt;m_cParent-&gt;GetSafeHwnd(),WM_VTK_UPDATE_WINDOW,1,NULL);<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;delete tmpdata;<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MultiLockObj = MultiLock.Lock( INFINITE, FALSE );<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp; &nbsp; &nbsp;while(1);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;//Cleanup<br>
 &nbsp; &nbsp; &nbsp; &nbsp;delete size;<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_Renderer-&gt;Delete();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_Win32OpenGLWindow-&gt;Delete();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_scale-&gt;Delete();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkImageReslicer-&gt;Delete();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_actor-&gt;Delete();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtk_slicetransform-&gt;Delete();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;::AfxEndThread( 0, true );<br>
 &nbsp; &nbsp; &nbsp; &nbsp;return 0L;<br>
<br>
&nbsp;}<br>
<br>
<br>
<br>
<br>
Does anybody has an idea why i cant delete vtk objects in a thread? i tried already to cut the connections between vtkobjects in the different threads, but it also doesnŽt helped.<br>
<br>
Thanks in advance<br>
Andi<br>
<br>
<br>
________________________________________________________________________<br>
Schon gehört? Bei <a href="http://WEB.DE" target="_blank">WEB.DE</a> gibt&#39; s viele kostenlose Spiele:<br>
<a href="http://games.entertainment.web.de/de/entertainment/games/free/index.html" target="_blank">http://games.entertainment.web.de/de/entertainment/games/free/index.html</a><br>
<br>
_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Julian Ibarz<br>
</div>