# Free memory and delete links of VTKSmartPointer Polydata

**URL:** https://discourse.itk.org/t/free-memory-and-delete-links-of-vtksmartpointer-polydata/2130
**Category:** Uncategorized
**Created:** [August 7, 2019, 8:36pm UTC](https://discourse.itk.org/t/free-memory-and-delete-links-of-vtksmartpointer-polydata/2130 "2019-08-07T20:36:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![srbn.ghosh89](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/3ec8ea/32.png) [@srbn.ghosh89](https://discourse.itk.org/u/srbn.ghosh89)
#### Post date: [August 7, 2019, 8:36pm UTC](https://discourse.itk.org/t/free-memory-and-delete-links-of-vtksmartpointer-polydata/2130/1 "2019-08-07T20:36:33Z")

</div>

Hi,

In my mesh, there are 642473 cells and 1275549 points.  
I want to replace cell of the mesh and after replacement, I want to reassign the mesh on the same name. But before reassign how can I free the memory and delete all the links of the previous one.

Using Below code, it’s not freeing the mesh and I am getting the “Killed” message.

auto result = ReplaceCells(mesh,i);  
vtkSmartPointer mesh=vtkSmartPointer::New();  
mesh = std::get\<0\>(result);

Thanks in advance.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [August 7, 2019, 9:30pm UTC](https://discourse.itk.org/t/free-memory-and-delete-links-of-vtksmartpointer-polydata/2130/2 "2019-08-07T21:30:29Z")

</div>

This is a VTK-related question, and should be posted on [VTK discourse](https://discourse.vtk.org/).

---

<div class="post-metadata">

### Author: ![srbn.ghosh89](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/3ec8ea/32.png) [@srbn.ghosh89](https://discourse.itk.org/u/srbn.ghosh89)
#### Post date: [August 7, 2019, 9:34pm UTC](https://discourse.itk.org/t/free-memory-and-delete-links-of-vtksmartpointer-polydata/2130/3 "2019-08-07T21:34:01Z")

</div>

Sorry bout that.
