If I create a vtkDenseArray of pointers, then create a smart pointer to an object, store it in the dense array, then let the smart pointer go out of scope, shouldn&#39;t it know that it is still needed in the dense array so it should not delete the memory? I looked at the reference count and it does not increase when the object is added to the array with SetValue.<br>
<br>Here is what I was trying to do:<br><br>  vtkSmartPointer&lt;vtkDenseArray&lt;vtkRay*&gt; &gt; array = vtkSmartPointer&lt;vtkDenseArray&lt;vtkRay*&gt; &gt;::New();<br>  array-&gt;Resize(5,1);<br>  <br>  for(unsigned int i = 0; i &lt; 5; i++)<br>
  {<br>    vtkSmartPointer&lt;vtkRay&gt; Ray = vtkSmartPointer&lt;vtkRay&gt;::New();<br>    double origin[3] = {0.0, 0.0, 0.0};<br>    double direction[3] = {1.0, 0.0, 0.0};<br>    Ray-&gt;SetOrigin(origin);<br>    Ray-&gt;SetDirection(direction);<br>
<b>//reference count of Ray here is 1</b><br>    array-&gt;SetValue(i, 0, Ray);<br><b>//reference count of array-&gt;GetValue(i,0) here is 1</b><br>    vtkRay* RetrievedRay = array-&gt;GetValue(i,0);<br>    vtkstd::cout &lt;&lt; *(RetrievedRay) &lt;&lt; vtkstd::endl;<br>
  }<br>  <br>  for(unsigned int i = 0; i &lt; 5; i++)<br>  {<br>    vtkRay* RetrievedRay = array-&gt;GetValue(i,0);<br>    vtkstd::cout &lt;&lt; *(RetrievedRay) &lt;&lt; vtkstd::endl;<b> //segfault occurs here</b><br>  }<br>
<br>Is vtkDenseArray not designed to be used like this?<br><br>Thanks,<br><br>David<br>