<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks for the reply! The problem seems to be in the actual SetPoints method though, which dereferences the parameter points. On the contrary, SetFieldData() and SetVerts() work exactly as expected, i.e. they increase the reference count of the passed parameter and so the Delete fxn works to properly memory manage. I tested that by moving the field data and cells lines above the point data. <div><br></div><div>While syntactically the same, for some reason, the SetPoints line always crashes my program, and when examining the variable "points" in debugging mode, it gets instantiated correctly with refCount 1, and then SetPoints just sets the ref count to 0. Another weird thing is with the following code:<div><br></div><div><blockquote type="cite"><div bgcolor="#FFFFFF"><blockquote type="cite"><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(113, 49, 168); "><span style="color: rgb(0, 0, 0); "><span class="Apple-tab-span" style="white-space: pre; "> </span></span>vtkPoints<span style="color: rgb(0, 0, 0); ">* points = </span>vtkPoints<span style="color: rgb(0, 0, 0); ">::</span><span style="color: rgb(64, 12, 128); ">New</span><span style="color: rgb(0, 0, 0); ">(); // Ref Count = 1</span></div></div></blockquote></div></blockquote><span class="Apple-tab-span" style="white-space:pre"> </span> points->Register(NULL); // Ref Count = 2<br><blockquote type="cite"><div bgcolor="#FFFFFF"><blockquote type="cite"><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space: pre; "> </span>model-><span style="color: rgb(64, 12, 128); ">SetPoints</span>(points); // Ref Count = 0!!!!!</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space: pre; "> </span>points-><span style="color: rgb(64, 12, 128); ">Delete</span>(); // PROGRAM CRASHES</div></div></blockquote></div></blockquote><div><br></div><div><br></div><div>I just wanted to try to increase the reference count of "points" to see whether the SetPoints method was automatically reducing the reference count by 1. If it was, then the SetPoints method should make points have a refCount of 1, but it still makes it 0 for some reason, and thus my program still crashes.</div><div><br></div><div>I should mention that the original code sample I sent fully compiles and executes properly under VTK 5.4.2 in OSX, 64 bit. This is only a program error in VTK 5.6.1, which is why I mentioned the detailed library compilation I used to build VTK earlier. I am in particular worried about taking out the -fobjc-gc line in the CMake settings, VTK_REQUIRED_OBJCXX_FLAGS:STRING="", leaving it blank instead so that I could get it to work with Qt 4.7.1. I built VTK with Cocoa, static libraries, and x86_64 architecture.</div><div><br></div>Ragu</div><div><br><div><div>On Dec 19, 2010, at 11:48 AM, Ignaz Reicht wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div bgcolor="#FFFFFF"><div>Hv u tried using vtkSmartpointers instead of "Common"pointers? When using them u don't hv to Care about deleting Pointers. <br><br>Am 19.12.2010 um 12:12 schrieb Ragu Vijaykumar <<a href="mailto:ragu@myosight.org">ragu@myosight.org</a>>:<br><br></div><div></div><blockquote type="cite"><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(113, 49, 168); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">H</span>i all,</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(113, 49, 168); "><span style="color: #000000"><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(113, 49, 168); "><span style="color: #000000">This is my first time posting to this list, so I hope someone out there can help me. I have the following code that needs to create a model that I will specify. I am using VTK 5.6.1 under OSX 10.6.5 with Cocoa build and RelWithDebInfo, linked with Qt 4.7, and </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre">VTK_REQUIRED_OBJCXX_FLAGS:STRING=""</span> to get it to work with Qt.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">The issue lies with the SetPoints method, which seems to automatically delete the parameter 'Points'. I stepped through the debugger, and it shows that the method makes points reference count 0 from 1, while the fielddata and cells lines all work as expected. My program crashes on 'points->Delete' everytime, and I'm not sure why?</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(113, 49, 168); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span>vtkPolyData<span style="color: #000000">* model = </span>vtkPolyData<span style="color: #000000">::</span><span style="color: #400c80">New</span><span style="color: #000000">();</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #7131a8">cout</span> << model-><span style="color: #400c80">GetPoints</span>() << endl;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(113, 49, 168); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span>vtkPoints<span style="color: #000000">* points = </span>vtkPoints<span style="color: #000000">::</span><span style="color: #400c80">New</span><span style="color: #000000">();</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"> </span>model-><span style="color: #400c80">SetPoints</span>(points);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"> </span>points-><span style="color: #400c80">Delete</span>();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(113, 49, 168); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span>vtkFieldData<span style="color: #000000">* fieldData = </span>vtkFieldData<span style="color: #000000">::</span><span style="color: #400c80">New</span><span style="color: #000000">();</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"> </span>model-><span style="color: #400c80">SetFieldData</span>(fieldData);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"> </span>fieldData-><span style="color: #400c80">Delete</span>();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(113, 49, 168); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span>vtkCellArray<span style="color: #000000">* cells = </span>vtkCellArray<span style="color: #000000">::</span><span style="color: #400c80">New</span><span style="color: #000000">();</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"> </span>model-><span style="color: #400c80">SetVerts</span>(cells);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"> </span>cells-><span style="color: #400c80">Delete</span>();<span class="Apple-tab-span" style="white-space:pre"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre">R</span>agu</div></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Powered by <a href="http://www.kitware.com/"></a><a href="http://www.kitware.com/">www.kitware.com</a></span><br><span></span><br><span>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html"></a><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></span><br><span></span><br><span>Follow this link to subscribe/unsubscribe:</span><br><span><a href="http://www.vtk.org/mailman/listinfo/vtk-developers">http://www.vtk.org/mailman/listinfo/vtk-developers</a></span><br><span></span><br></div></blockquote></div></blockquote></div><br></div></div></body></html>