<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
I don't see anything wrong in your code snippet.&nbsp; Given all the information I have, I can only say this:<br><br>1. if the crash occurs consistently, make sure you you're dealing with exactly one vtk code base and using the exact same compiler.<br>2. if the crash occurs randomly, check for racing condition between threads.<br><br><br><br><br><br><div><hr id="stopSpelling">Date: Thu, 8 Sep 2011 20:03:58 -0700<br>Subject: Re: [vtkusers] Help with crashes in VTK<br>From: jonmorra@gmail.com<br>To: xf10036@hotmail.com<br>CC: david.gobbi@gmail.com; vtkusers@vtk.org<br><br>So I've spent a bunch of time and removed all the references to vtkSmartPointer. &nbsp;I'm still getting a lot of crashes. &nbsp;Here is an example of a crash that I just got without any use of vtkSmartPointers<div><br></div>
<div>My code</div><div><br></div><div><div>vtkPolyData* vtkPipelines::getOrganMesh(vtkImageData * const binaryImage) {</div><div>&nbsp; &nbsp; vtkPolyData *returnedData = NULL;</div><div><br></div><div>&nbsp; &nbsp; vtkMarchingCubes *marching = vtkMarchingCubes::New();</div>
<div>&nbsp; &nbsp; marching-&gt;SetInput(binaryImage);</div><div>&nbsp; &nbsp; marching-&gt;ComputeGradientsOff();</div><div>&nbsp; &nbsp; marching-&gt;ComputeNormalsOff();</div><div>&nbsp; &nbsp; marching-&gt;ComputeScalarsOff();</div><div>&nbsp; &nbsp; marching-&gt;SetValue(0, 0.5);</div>
<div>&nbsp; &nbsp; if (marching-&gt;GetOutput()-&gt;GetNumberOfPoints() &gt; 0) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; // The decimation makes the render time much faster</div><div>&nbsp; &nbsp; &nbsp; &nbsp; vtkDecimatePro* decimate = vtkDecimatePro::New();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; decimate-&gt;SetInputConnection(marching-&gt;GetOutputPort());</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; decimate-&gt;SetTargetReduction(0.6);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; decimate-&gt;Update();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; returnedData = vtkPolyData::New();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; returnedData-&gt;DeepCopy(decimate-&gt;GetOutput());</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; decimate-&gt;Delete();</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; else {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; marching-&gt;Update();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; returnedData = vtkPolyData::New();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; returnedData-&gt;DeepCopy(marching-&gt;GetOutput());</div>
<div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; marching-&gt;Delete(); // Last line of my code before crash occurs</div><div>&nbsp; &nbsp; return returnedData;</div><div>}</div><div><br></div><div>Stack Trace</div><div><div>&nbsp;<span class="ecxApple-tab-span" style="white-space: pre;">        </span>4a8bdc42()<span class="ecxApple-tab-span" style="white-space: pre;">        </span></div>
<div>&nbsp;<span class="ecxApple-tab-span" style="white-space: pre;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::CollectComponent(vtkGarbageCollectorImpl::ComponentType * c=0x073d0c18) &nbsp;Line 702 + 0x2b bytes<span class="ecxApple-tab-span" style="white-space: pre;">        </span>C++</div>
<div>&nbsp;<span class="ecxApple-tab-span" style="white-space: pre;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::CollectInternal(vtkObjectBase * root=0x07ac2dc8) &nbsp;Line 476<span class="ecxApple-tab-span" style="white-space: pre;">        </span>C++</div>
<div>&nbsp;<span class="ecxApple-tab-span" style="white-space: pre;">        </span>vtkCommon.dll!vtkGarbageCollector::Collect(vtkObjectBase * root=0x07ac2dc8) &nbsp;Line 907<span class="ecxApple-tab-span" style="white-space: pre;">        </span>C++</div>
<div>&nbsp;<span class="ecxApple-tab-span" style="white-space: pre;">        </span>vtkCommon.dll!vtkObjectBase::UnRegisterInternal(vtkObjectBase * __formal=0x00000000, int check=1) &nbsp;Line 287 + 0x6 bytes<span class="ecxApple-tab-span" style="white-space: pre;">        </span>C++</div>
<div>&nbsp;<span class="ecxApple-tab-span" style="white-space: pre;">        </span>vtkCommon.dll!vtkObject::UnRegisterInternal(vtkObjectBase * o=0x00000000, int check=1) &nbsp;Line 885 + 0x11 bytes<span class="ecxApple-tab-span" style="white-space: pre;">        </span>C++</div>
<div>&nbsp;<span class="ecxApple-tab-span" style="white-space: pre;">        </span>vtkFiltering.dll!vtkAlgorithm::UnRegister(vtkObjectBase * o=0x00000000) &nbsp;Line 918<span class="ecxApple-tab-span" style="white-space: pre;">        </span>C++</div><div>
&nbsp;<span class="ecxApple-tab-span" style="white-space: pre;">        </span>vtkCommon.dll!vtkObjectBase::Delete() &nbsp;Line 128<span class="ecxApple-tab-span" style="white-space: pre;">        </span>C++</div><div>&gt;<span class="ecxApple-tab-span" style="white-space: pre;">        </span>MVSOrganizerQt.exe!vtkPipelines::getOrganMesh(vtkImageData * const binaryImage=0x118a7190) &nbsp;Line 507 + 0x9 bytes<span class="ecxApple-tab-span" style="white-space: pre;">        </span>C++</div>
<div>&nbsp;<span class="ecxApple-tab-span" style="white-space: pre;">        </span>MVSOrganizerQt.exe!CreateOrganMeshThread::doOrganCreation() &nbsp;Line 30 + 0x6 bytes<span class="ecxApple-tab-span" style="white-space: pre;">        </span>C++</div></div>
<div><div><span class="ecxApple-tab-span" style="white-space: pre;">        </span></div></div><div>I'm getting very discouraged trying to fix all of these crashes. &nbsp;Can anyone suggest some reason for this?</div><div><br></div><div>
If it matters, this is being called from a thread (although other crashes do not occur in threads)</div><br><div class="ecxgmail_quote">On Wed, Sep 7, 2011 at 4:40 PM, Xiaofeng Z <span dir="ltr">&lt;<a href="mailto:xf10036@hotmail.com">xf10036@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="ecxgmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">



<div><div dir="ltr">
vtk doesn't use thread to do garbage collection.&nbsp; You have too thread running vtk code and your crashes are most likely related to a race condition.<br><br><br>&nbsp;<br><div><hr>Date: Wed, 7 Sep 2011 14:14:48 -0700<div class="ecxim">
<br>Subject: Re: [vtkusers] Help with crashes in VTK<br>From: <a href="mailto:jonmorra@gmail.com">jonmorra@gmail.com</a><br></div>To: <a href="mailto:xf10036@hotmail.com">xf10036@hotmail.com</a>; <a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a><br>
CC: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br><div><div></div><div class="h5"><br>So I was playing around with removing vtkSmartPointers passed by reference to see if that fixed my issue.<div>
1. &nbsp;Would passing a vtkSmartPointer by const reference be an issue?</div><div>2. &nbsp;I got the following crash outlined below. &nbsp;It does not reference any code I wrote at all. &nbsp;Also in my debugger it says that there are 2 vtk garbage collection threads running. &nbsp;My understanding of smart pointers is that a garbage collector is unnecessary because if the reference count = 0 then the object is removed. &nbsp;Also, what could cause this crash?</div>

<div><br></div><div>Thread 1 stack trace</div><div><div>&nbsp;<span style="white-space: pre-wrap;">        </span>cccccccc()<span style="white-space: pre-wrap;">        </span></div><div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x0687f280) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x179ff5f4) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f82880, void * ptr=0x04047640) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f82880, void * ptr=0x04047640, const char * __formal=0x6490d51c) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x179ffd90, vtkObjectBase * obj=0x03f82880, void * ptr=0x04047640, const char * desc=0x6490d51c) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkGarbageCollectorReport&lt;vtkInformation&gt;(vtkGarbageCollector * collector=0x179ffd90, vtkInformation * &amp; ptr=, const char * desc=0x6490d51c) &nbsp;Line 201 + 0x18 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkDataObject::ReportReferences(vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 1022<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkPointSet::ReportReferences(vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 351<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x0687f168) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x179ff718) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x04047618, void * ptr=0x06bf9270) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x04047618, void * ptr=0x06bf9270, const char * __formal=0x6490cc14) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x179ffd90, vtkObjectBase * obj=0x04047618, void * ptr=0x06bf9270, const char * desc=0x6490cc14) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReport&lt;vtkObjectBase&gt;(vtkGarbageCollector * collector=0x179ffd90, vtkObjectBase * &amp; ptr=, const char * desc=0x6490cc14) &nbsp;Line 201 + 0x17 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkInformation::ReportAsObjectBase(vtkInformationKey * key=0x03ef5f78, vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 826 + 0x16 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkInformationKey::ReportAsObjectBase(vtkInformation * info=0x03f86bd8, vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 136<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkInformation::ReportReferences(vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 812 + 0xc bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x0687f248) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x179ff864) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f86bd8, void * ptr=0x03f84698) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f86bd8, void * ptr=0x03f84698, const char * __formal=0x6571055c) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x179ffd90, vtkObjectBase * obj=0x03f86bd8, void * ptr=0x03f84698, const char * desc=0x6571055c) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReport&lt;vtkInformation&gt;(vtkGarbageCollector * collector=0x179ffd90, vtkInformation * &amp; ptr=, const char * desc=0x6571055c) &nbsp;Line 201 + 0x17 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkInformationVector::ReportReferences(vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 227 + 0x28 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x06983e58) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x179ff980) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f85968, void * ptr=0x03c6bb08) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f85968, void * ptr=0x03c6bb08, const char * __formal=0x64910f5c) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x179ffd90, vtkObjectBase * obj=0x03f85968, void * ptr=0x03c6bb08, const char * desc=0x64910f5c) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkGarbageCollectorReport&lt;vtkInformationVector&gt;(vtkGarbageCollector * collector=0x179ffd90, vtkInformationVector * &amp; ptr=, const char * desc=0x64910f5c) &nbsp;Line 201 + 0x18 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkExecutive::ReportReferences(vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 306 + 0xf bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x06983c60) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x179ffa9c) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03c6bae0, void * ptr=0x03fd5f44) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03c6bae0, void * ptr=0x03fd5f44, const char * __formal=0x64910cac) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x179ffd90, vtkObjectBase * obj=0x03c6bae0, void * ptr=0x03fd5f44, const char * desc=0x64910cac) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReport&lt;vtkObjectBase&gt;(vtkGarbageCollector * collector=0x179ffd90, vtkObjectBase * &amp; ptr=, const char * desc=0x64910cac) &nbsp;Line 201 + 0x17 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkSmartPointerBase::Report(vtkGarbageCollector * collector=0x179ffd90, const char * desc=0x64910cac) &nbsp;Line 96 + 0x10 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkInformationExecutivePortKey::Report(vtkInformation * info=0x03f84158, vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 157 + 0x17 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkInformation::ReportReferences(vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 812 + 0xc bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x06983d08) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x179ffbe0) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f84158, void * ptr=0x04047464) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f84158, void * ptr=0x04047464, const char * __formal=0x6490d504) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x179ffd90, vtkObjectBase * obj=0x03f84158, void * ptr=0x04047464, const char * desc=0x6490d504) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkGarbageCollectorReport&lt;vtkInformation&gt;(vtkGarbageCollector * collector=0x179ffd90, vtkInformation * &amp; ptr=, const char * desc=0x6490d504) &nbsp;Line 201 + 0x18 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkDataObject::ReportReferences(vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 1022 + 0xf bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkPointSet::ReportReferences(vtkGarbageCollector * collector=0x179ffd90) &nbsp;Line 351<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x06983b48) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&gt;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x02fe0000) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>kernel32.dll!762214dd() <span style="white-space: pre-wrap;">        </span></div><div>&nbsp;<span style="white-space: pre-wrap;">        </span>[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]<span style="white-space: pre-wrap;">        </span></div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>msvcr90.dll!73193c3a() <span style="white-space: pre-wrap;">        </span></div><div>&nbsp;<span style="white-space: pre-wrap;">        </span>msvcr90.dll!731534c7() <span style="white-space: pre-wrap;">        </span></div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>kernel32.dll!7622339a() <span style="white-space: pre-wrap;">        </span></div><div>&nbsp;<span style="white-space: pre-wrap;">        </span>ntdll.dll!76f69ed2() <span style="white-space: pre-wrap;">        </span></div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>ntdll.dll!76f69ea5() <span style="white-space: pre-wrap;">        </span></div></div><div><br></div><div>Thread 2 stack trace</div><div><span style="white-space: pre-wrap;">        </span><span style="white-space: pre-wrap;">        </span></div>

<div><div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x06718db8) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x17aff5f4) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f82880, void * ptr=0x04047640) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f82880, void * ptr=0x04047640, const char * __formal=0x6490d51c) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x17affd90, vtkObjectBase * obj=0x03f82880, void * ptr=0x04047640, const char * desc=0x6490d51c) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkGarbageCollectorReport&lt;vtkInformation&gt;(vtkGarbageCollector * collector=0x17affd90, vtkInformation * &amp; ptr=, const char * desc=0x6490d51c) &nbsp;Line 201 + 0x18 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkDataObject::ReportReferences(vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 1022<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkPointSet::ReportReferences(vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 351<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x06679c80) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x17aff718) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x04047618, void * ptr=0x06bf9270) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x04047618, void * ptr=0x06bf9270, const char * __formal=0x6490cc14) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x17affd90, vtkObjectBase * obj=0x04047618, void * ptr=0x06bf9270, const char * desc=0x6490cc14) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReport&lt;vtkObjectBase&gt;(vtkGarbageCollector * collector=0x17affd90, vtkObjectBase * &amp; ptr=, const char * desc=0x6490cc14) &nbsp;Line 201 + 0x17 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkInformation::ReportAsObjectBase(vtkInformationKey * key=0x03ef5f78, vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 826 + 0x16 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkInformationKey::ReportAsObjectBase(vtkInformation * info=0x03f86bd8, vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 136<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkInformation::ReportReferences(vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 812 + 0xc bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x06679c10) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x17aff864) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f86bd8, void * ptr=0x03f84698) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f86bd8, void * ptr=0x03f84698, const char * __formal=0x6571055c) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x17affd90, vtkObjectBase * obj=0x03f86bd8, void * ptr=0x03f84698, const char * desc=0x6571055c) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReport&lt;vtkInformation&gt;(vtkGarbageCollector * collector=0x17affd90, vtkInformation * &amp; ptr=, const char * desc=0x6571055c) &nbsp;Line 201 + 0x17 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkInformationVector::ReportReferences(vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 227 + 0x28 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x06717548) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x17aff980) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f85968, void * ptr=0x03c6bb08) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f85968, void * ptr=0x03c6bb08, const char * __formal=0x64910f5c) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x17affd90, vtkObjectBase * obj=0x03f85968, void * ptr=0x03c6bb08, const char * desc=0x64910f5c) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkGarbageCollectorReport&lt;vtkInformationVector&gt;(vtkGarbageCollector * collector=0x17affd90, vtkInformationVector * &amp; ptr=, const char * desc=0x64910f5c) &nbsp;Line 201 + 0x18 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkExecutive::ReportReferences(vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 306 + 0xf bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x067174d8) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x17affa9c) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03c6bae0, void * ptr=0x03fd6624) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03c6bae0, void * ptr=0x03fd6624, const char * __formal=0x64910cac) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x17affd90, vtkObjectBase * obj=0x03c6bae0, void * ptr=0x03fd6624, const char * desc=0x64910cac) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReport&lt;vtkObjectBase&gt;(vtkGarbageCollector * collector=0x17affd90, vtkObjectBase * &amp; ptr=, const char * desc=0x64910cac) &nbsp;Line 201 + 0x17 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkSmartPointerBase::Report(vtkGarbageCollector * collector=0x17affd90, const char * desc=0x64910cac) &nbsp;Line 96 + 0x10 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkInformationExecutivePortKey::Report(vtkInformation * info=0x03f84b30, vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 157 + 0x17 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkInformation::ReportReferences(vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 812 + 0xc bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x067173f8) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x17affbe0) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f84b30, void * ptr=0x04046ce4) &nbsp;Line 639<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::Report(vtkObjectBase * obj=0x03f84b30, void * ptr=0x04046ce4, const char * __formal=0x6490d504) &nbsp;Line 602<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorReportInternal(vtkGarbageCollector * collector=0x17affd90, vtkObjectBase * obj=0x03f84b30, void * ptr=0x04046ce4, const char * desc=0x6490d504) &nbsp;Line 1069<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkGarbageCollectorReport&lt;vtkInformation&gt;(vtkGarbageCollector * collector=0x17affd90, vtkInformation * &amp; ptr=, const char * desc=0x6490d504) &nbsp;Line 201 + 0x18 bytes<span style="white-space: pre-wrap;">        </span>C++</div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkDataObject::ReportReferences(vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 1022 + 0xf bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkFiltering.dll!vtkPointSet::ReportReferences(vtkGarbageCollector * collector=0x17affd90) &nbsp;Line 351<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::VisitTarjan(vtkObjectBase * obj=0x067175f0) &nbsp;Line 552<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&gt;<span style="white-space: pre-wrap;">        </span>vtkCommon.dll!vtkGarbageCollectorImpl::MaybeVisit(vtkObjectBase * obj=0x00000000) &nbsp;Line 522 + 0x8 bytes<span style="white-space: pre-wrap;">        </span>C++</div>
<div>&nbsp;<span style="white-space: pre-wrap;">        </span>QtGui4.dll!009284f2() <span style="white-space: pre-wrap;">        </span></div><div>&nbsp;<span style="white-space: pre-wrap;">        </span>kernel32.dll!762214dd() <span style="white-space: pre-wrap;">        </span></div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>msvcr90.dll!73193c3a() <span style="white-space: pre-wrap;">        </span></div><div>&nbsp;<span style="white-space: pre-wrap;">        </span>msvcr90.dll!731534c7() <span style="white-space: pre-wrap;">        </span></div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>kernel32.dll!7622339a() <span style="white-space: pre-wrap;">        </span></div><div>&nbsp;<span style="white-space: pre-wrap;">        </span>ntdll.dll!76f69ed2() <span style="white-space: pre-wrap;">        </span></div>

<div>&nbsp;<span style="white-space: pre-wrap;">        </span>ntdll.dll!76f69ea5() <span style="white-space: pre-wrap;">        </span></div></div><div><br></div><div><br><div>On Wed, Sep 7, 2011 at 9:45 AM, Xiaofeng Z <span dir="ltr">&lt;<a href="mailto:xf10036@hotmail.com">xf10036@hotmail.com</a>&gt;</span> wrote:<br>

<blockquote style="padding-left: 1ex; border-left: 1px solid rgb(204, 204, 204);">



<div><div dir="ltr"><div>
&gt;I've been using vtkImageData::New(), followed by vtkImageData-&gt;DeepCopy(filter-&gt;GetOutput()). &nbsp;I've been doing this cause I notice that once I delete the filter the output no longer exists.<br></div><div>


<div>&nbsp;</div><div>Don't deep copy the image, instead do:</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp; vtkImageData* filterOutput = filter-&gt;GetOutput();</div><div>&nbsp;&nbsp;&nbsp; filterOutput-&gt;Register(0);&nbsp;&nbsp;&nbsp; // increment the ref count</div><div>

&nbsp;</div><div>to keep the output in the memory.</div><div>&nbsp;</div><div>Just make sure you pair off every New() or Register() with a Delete().</div><div>&nbsp;</div><div>BTW, I'm not for or against the use of smart pointer for any fundamental reason.&nbsp; If one knows very well how a smart pointer class works,&nbsp;using the&nbsp;smart pointer&nbsp;to&nbsp;left the burden of tracking memory allocation can be very helpful.&nbsp; When I do decided to use smart pointer, I use it exclusively, much like in Java where every variable is a managed smart pointer.&nbsp; Mixing the usage of smart pointers and naked pointers is where trouble comes in.</div>

<div>&nbsp;</div><div>HTH</div><div><div><br><div>On Tue, Sep 6, 2011 at 11:55 AM, David Gobbi <span dir="ltr">&lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;</span> wrote:<br>

<blockquote style="padding-left: 1ex; border-left: 1px solid rgb(204, 204, 204);"><div><div>On Tue, Sep 6, 2011 at 12:34 PM, Jonathan Morra <span dir="ltr">&lt;<a href="mailto:jonmorra@gmail.com">jonmorra@gmail.com</a>&gt;</span> wrote:<br>


<div><blockquote style="padding-left: 1ex; border-left: 1px solid rgb(204, 204, 204);">

This could make sense, I'm going to try and change all my method signatures to pass around const references to vtkSmartPointers where appropriate. &nbsp;Do you know what happens to the reference count upon returning a vtkSmartPointer?</blockquote>




</div><br></div><div><br></div></div><div>In VTK, smart pointers should only be used to store references, not to pass them.&nbsp;&nbsp;VTK methods should take regular pointers as arguments.</div><div><br></div><div>The general rules are:</div>




<div><br></div><div>1) Refcounts are not automatically incremented when objects are returned, i.e. when an object is returned to you, then you are just "borrowing" it. &nbsp;If you need to own it for a while, then store it in a smart pointer.</div>




<div><br></div><div>2) Refcounts are not automatically incremented when objects are passed to a method. &nbsp;If a method needs to own the object for a while, it should store it in a smart pointer. &nbsp;All methods in the VTK libraries that need to own the objects that are passed to them will increment the refcount of those objects, either by storing it in a smart pointer or by calling Register() on it.</div>




<div><br></div><div>There are a few very rare exceptions to rule #1, such as the NewInstance() method.</div><div><br></div><font color="#888888"><div>&nbsp;- David</div>
</font></blockquote></div><br></div></div></div>                                               </div></div>
</blockquote></div><br></div></div></div></div>                                               </div></div>
</blockquote></div><br></div></div>                                               </div></body>
</html>