<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi all,<div><br></div><div>I've got a problem for freeing memory with VTK 5.2.</div><div>In my program, I've got a function that allows to switch between a line representation and a sphere representations.</div><div>Each time I switch, I pay attention to remove the actor from the renderer then delete the actor before initializing it again.</div><div><br></div><div>But when I use Apple Instruments to check for memory leaks, I can see that there is not memory leak (good point) but that the memory usage increases every time I switch from lines to spheres (see picture).</div><div><br></div><div>Does anyone have an idea of what am I doing wrong ?</div><div><br></div><div>Any help would be appreciated.</div><div>Thanks.</div><div>Ben.</div><div><br></div><div><br></div><div>Here is the code.</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; ">void switchRepresentationToLines()</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>deleteActor();</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; min-height: 13px; "><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPolyDataMapper * mapper = vtkPolyDataMapper::New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>mapper->SetInput(_data);</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; min-height: 13px; "><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>_actor = vtkActor::New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>_actor->SetMapper(mapper);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; 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 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>_renderer->AddActor(_actor);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>updateDisplay();</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; min-height: 13px; "><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>mapper->Delete();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; 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 'DejaVu Sans Mono'; ">void switchRepresentationToSpheres()</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>deleteActor();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSphereSource * sphereSource = vtkSphereSource::New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>sphereSource->SetThetaResolution(10.0);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>sphereSource->SetPhiResolution(10.0);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>sphereSource->SetRadius(1.0);</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; min-height: 13px; "><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>vtkGlyph3D * glyph = vtkGlyph3D::New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>glyph->SetInput(_data);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>glyph->SetSourceConnection(sphereSource->GetOutputPort());</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>glyph->SetVectorModeToUseNormal();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>glyph->SetScaleModeToScaleByVector();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>glyph->SetScaleFactor(0.5);</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; min-height: 13px; "><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPolyDataMapper * mapper = vtkPolyDataMapper::New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>mapper->ImmediateModeRenderingOn();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>mapper->SetInputConnection(glyph->GetOutputPort());</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; min-height: 13px; "><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>_actor = vtkActor::New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>_actor->SetMapper(mapper);</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; min-height: 13px; "><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>_renderer->AddActor(_actor);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>updateDisplay();</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; min-height: 13px; "><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>sphereSource->Delete();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>glyph->Delete();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; ">void deleteActor()</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </span>if (actor)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><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 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">                </span>_renderer->RemoveActor(_actor);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">                </span>_actor->Delete();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">                </span>_actor = NULL;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><span class="Apple-tab-span" style="white-space:pre">        </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 'DejaVu Sans Mono'; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><img height="95" width="389" apple-width="yes" apple-height="yes" src="cid:C042B223-007A-4F70-B587-F7FB04BCB3F6"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal 'DejaVu Sans Mono'; "><br></div></div></div></body></html>