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

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

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