# Unable to allocate memory for merge block during coprocessing

**URL:** https://discourse.paraview.org/t/unable-to-allocate-memory-for-merge-block-during-coprocessing/2359
**Category:** ParaView Support
**Created:** [August 5, 2019, 3:26pm UTC](https://discourse.paraview.org/t/unable-to-allocate-memory-for-merge-block-during-coprocessing/2359 "2019-08-05T15:26:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kschau](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/a5b964/32.png) [@kschau](https://discourse.paraview.org/u/kschau)
#### Post date: [August 5, 2019, 3:26pm UTC](https://discourse.paraview.org/t/unable-to-allocate-memory-for-merge-block-during-coprocessing/2359/1 "2019-08-05T15:26:41Z")

</div>

I am getting a std::bad\_alloc when using the merge block feature in a Catalyst script.

```
ERROR: In ParaView/VTK/Common/Core/vtkGenericDataArray.txx, line 452
vtkIdTypeArray (0x2aab39a989f0): Unable to allocate 154940 elements of size 8 bytes.

```

Without the merge block operation (keeping everything downstream the same) it works fine, but I would like to reduce my file output (hence the merge).

Is there something I can do as a use to increase memory (the machine is no where near limited by RAM for this case) or is this perhaps an issue with mergeBlock, etc.??

Thanks for the help!

---

<div class="post-metadata">

### Author: ![kschau](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/a5b964/32.png) [@kschau](https://discourse.paraview.org/u/kschau)
#### Post date: [August 10, 2019, 12:58am UTC](https://discourse.paraview.org/t/unable-to-allocate-memory-for-merge-block-during-coprocessing/2359/3 "2019-08-10T00:58:19Z")

</div>

This actually is occurring regularly with my implementation, not just with merge blocks. I am linking with a fortran code. I do not think I am creating excessive data. Below is my adapter file that updates the data structures. I am using intel 17.0 compilers on RHEL 6 cluster.

```
extern "C" void updatefield_(int* nblki,
                         double* data,
                         char** name)
{
vtkCPInputDataDescription* idd = vtkCPPythonAdaptorAPI::GetCoProcessorData()- 
>GetInputDescriptionByName("input");
vtkMultiBlockDataSet* mbds = vtkMultiBlockDataSet::SafeDownCast(idd->GetGrid());
vtkMultiPieceDataSet* mpds = vtkMultiPieceDataSet::SafeDownCast(mbds->GetBlock(0));
vtkStructuredGrid* grid = vtkStructuredGrid::SafeDownCast(mpds->GetPiece((*nblki-1)));
int ncls = grid->GetNumberOfCells();
vtkDoubleArray* field = vtkDoubleArray::SafeDownCast(grid->GetCellData()->GetArray(*name));
//Check if field alrady exists
if (field == nullptr)
{
  vtkNew<vtkDoubleArray> newfield;
  newfield->SetNumberOfComponents(1);
  newfield->SetName(*name);
  newfield->SetNumberOfTuples(grid->GetNumberOfCells());
  for(int i=0; i<ncls; i++)
    {
      newfield->SetValue(i,*(data+i));
    }
  grid->GetCellData()->AddArray(newfield);
  }
//Update field
else
{
  for(int i=0; i<ncls; i++)
    {
      field->SetValue(i,*(data+i));
    }
}
}
```

---

<div class="post-metadata">

### Author: ![kschau](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/a5b964/32.png) [@kschau](https://discourse.paraview.org/u/kschau)
#### Post date: [September 28, 2019, 3:39pm UTC](https://discourse.paraview.org/t/unable-to-allocate-memory-for-merge-block-during-coprocessing/2359/4 "2019-09-28T15:39:30Z")

</div>

See this post for solution

> [@Inconsistent memory behavior in Catalyst](https://discourse.paraview.org/t/inconsistent-memory-behavior-in-catalyst/2444):
>
> I have implemented Catalyst into a Fortran-MPI research code. For now I am using the writers to write out reduced data sets like plotOverLine and Slices for visualization and analysis later. I have built ParaVeiw 5.6.1 from source and that has all gone well. The issue I am running into is, at random intervals, ParaView throwing ERROR: In ParaView/VTK/Common/Core/vtkGenericDataArray.txx, line 452 vtkIdTypeArray (0x2aab12f03e40): Unable to allocate XXXXX elements of size 8 bytes. This happen…
