# Is there any memory leak possibility due to some strange reference counts of VTK objects?

**URL:** https://discourse.paraview.org/t/is-there-any-memory-leak-possibility-due-to-some-strange-reference-counts-of-vtk-objects/516
**Category:** In Situ Support
**Created:** [September 4, 2018, 4:15pm UTC](https://discourse.paraview.org/t/is-there-any-memory-leak-possibility-due-to-some-strange-reference-counts-of-vtk-objects/516 "2018-09-04T16:15:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hsalimi](https://discourse.paraview.org/user_avatar/discourse.paraview.org/hsalimi/32/41_2.png) [@hsalimi](https://discourse.paraview.org/u/hsalimi)
#### Post date: [September 4, 2018, 4:15pm UTC](https://discourse.paraview.org/t/is-there-any-memory-leak-possibility-due-to-some-strange-reference-counts-of-vtk-objects/516/1 "2018-09-04T16:15:03Z")

</div>

Hi Everyone,

I have written a ParaView catalyst adaptor for my simulation. It is based on a `vtkMultiBlockDataSet` grid that is distributed over a set of processes. Here, is a partial code snippet of `CoProcess()` function of my adaptor:

```
if (processor_->RequestDataDescription(dataDescription) != 0) 
{
		vtkMultiBlockDataSet* rootGrid = vtkMultiBlockDataSet::New();
		cout << "RefCount in Step 1 is: " << rootGrid->GetReferenceCount() << endl;

		FillMultiBlockGrid(rootGrid);
		cout << "RefCount in Step 2 is: " << rootGrid->GetReferenceCount() << endl;
		
		dataDescription->GetInputDescriptionByName("input")->SetGrid(rootGrid);
		cout << "RefCount in Step 3 is: " << rootGrid->GetReferenceCount() << endl;

		processor_->CoProcess(dataDescription);
		cout << "RefCount in Step 4 is: " << rootGrid->GetReferenceCount() << endl;

		rootGrid->Delete();
		cout << "RefCount in Step 5 is: " << rootGrid->GetReferenceCount() << endl;
}

```

When the simulation is running, the output is like this:

```
RefCount in Step 1 is: 1
RefCount in Step 2 is: 1
RefCount in Step 3 is: 2
RefCount in Step 4 is: 4
RefCount in Step 5 is: 3

```

To me, the outputs of Step 1 and Step 2 are clear. Step 3 is also fine because dataDescription will be deleted at the end of the method. But should I care about the output of Step 4? Considering the fact that `processor_` is a member variable of my adaptor class (like ALL Catalyst examples), is there any memory leak probability in the simulation?

Thanks in advance,  
Hadi

---

<div class="post-metadata">

### Author: ![Joachim\_Pouderoux](https://discourse.paraview.org/user_avatar/discourse.paraview.org/joachim_pouderoux/32/38_2.png) [@Joachim\_Pouderoux](https://discourse.paraview.org/u/Joachim_Pouderoux)
#### Post date: [September 10, 2018, 1:27pm UTC](https://discourse.paraview.org/t/is-there-any-memory-leak-possibility-due-to-some-strange-reference-counts-of-vtk-objects/516/2 "2018-09-10T13:27:24Z")

</div>

Hi Hadi,

Internal objects keep references on your grid so this is OK if RefCount if not 0 after step 5.  
To be sure there is no leak, you can turn on the VTK\_DEBUG\_LEAKS in your Catalyst or PV’s build.

Best,  
Joachim
