# I found memory leak!!!

**URL:** https://discourse.vtk.org/t/i-found-memory-leak/7815
**Category:** Development
**Created:** [February 11, 2022, 6:15am UTC](https://discourse.vtk.org/t/i-found-memory-leak/7815 "2022-02-11T06:15:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![MincheolKim](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@MincheolKim](https://discourse.vtk.org/u/MincheolKim)
#### Post date: [February 11, 2022, 6:15am UTC](https://discourse.vtk.org/t/i-found-memory-leak/7815/1 "2022-02-11T06:15:12Z")

</div>

I find a problem and fixed it.  
The code is below.  
I think that you can find what is problem.  
Please update it in the next version.  
int vtkDataSetSurfaceFilter::UnstructuredGridExecute in vtkDataSetSurfaceFilter.cxx file.

```auto
int vtkDataSetSurfaceFilter::UnstructuredGridExecute(
  vtkDataSet* dataSetInput, vtkPolyData* output, vtkGeometryFilterHelper* info)
{
  vtkUnstructuredGrid* input = vtkUnstructuredGrid::SafeDownCast(dataSetInput);

  // If no info, then compute information about the unstructured grid.
  // Depending on the outcome, we may process the data ourselves, or send over
  // to the faster vtkGeometryFilter.
  bool mayDelegate = (info == nullptr && this->Delegation);
  if (info == nullptr)
  {
    info = vtkGeometryFilterHelper::CharacterizeUnstructuredGrid(input);
  }
  bool handleSubdivision = (!info->IsLinear);

  // Before we start doing anything interesting, check if we need handle
  // non-linear cells using sub-division.
  if (info->IsLinear && mayDelegate)
  {
    vtkNew<vtkGeometryFilter> gf;
    vtkGeometryFilterHelper::CopyFilterParams(this, gf.Get());
    gf->UnstructuredGridExecute(dataSetInput, output, info, nullptr);
    delete info;
    return 1;
  }

delete info; // I added!!!!!!!!!!!!!!!

  // If here, the data is gnarly and this filter will process it.
  vtkSmartPointer<vtkCellIterator> cellIter =
    vtkSmartPointer<vtkCellIterator>::Take(input->NewCellIterator());

  return this->UnstructuredGridExecuteInternal(input, output, handleSubdivision, cellIter);
}

```

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [February 11, 2022, 8:22am UTC](https://discourse.vtk.org/t/i-found-memory-leak/7815/2 "2022-02-11T08:22:38Z")

</div>

Awesome ! Could you open a MR on our gitlab ?

[https://gitlab.kitware.com/vtk/vtk/-/blob/master/Documentation/dev/git/develop.md](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Documentation/dev/git/develop.md)

---

<div class="post-metadata">

### Author: ![andreasbuykx](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andreasbuykx/32/8137_2.png) [@andreasbuykx](https://discourse.vtk.org/u/andreasbuykx)
#### Post date: [February 11, 2022, 11:00am UTC](https://discourse.vtk.org/t/i-found-memory-leak/7815/3 "2022-02-11T11:00:45Z")

</div>

It looks like the current master already has this memory leak fixed.  
[https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/Geometry/vtkDataSetSurfaceFilter.cxx#L1316](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/Geometry/vtkDataSetSurfaceFilter.cxx#L1316)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [February 11, 2022, 11:01am UTC](https://discourse.vtk.org/t/i-found-memory-leak/7815/4 "2022-02-11T11:01:33Z")

</div>

Thanks for checking @andreasbuykx !
