# Inconsistent memory behavior in Catalyst

**URL:** https://discourse.paraview.org/t/inconsistent-memory-behavior-in-catalyst/2444
**Category:** ParaView Support
**Tags:** catalyst
**Created:** [August 16, 2019, 1:38pm UTC](https://discourse.paraview.org/t/inconsistent-memory-behavior-in-catalyst/2444 "2019-08-16T13:38:53Z")
**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 16, 2019, 1:38pm UTC](https://discourse.paraview.org/t/inconsistent-memory-behavior-in-catalyst/2444/1 "2019-08-16T13:38:53Z")

</div>

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

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

```

This happens at seemingly random intervals. I.e. one run will do this at iteration X, and rerunning the exact simulation will do it at iteration Y.

I have tried about 1000 different ways of accessing, creating, modifying, etc the data arrays in the Adapter.cxx script for my code, however the behavior never changes. My RAM is no where near capacity either, nor should my executable allowable memory be.

I am a bit at a loss at this point, as it has happened with every case of reasonable size (none of these cases are egregiously large).

Any help on this would be greatly appreciated.

---

<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:37pm UTC](https://discourse.paraview.org/t/inconsistent-memory-behavior-in-catalyst/2444/2 "2019-09-28T15:37:45Z")

</div>

For me, the solution to this problem was during the step of creating my grid. In many of the Catalyst examples, the “points” array is created by just inserting the next point sequentially.

Apparently, when this method is used, vtk will double the allocated memory each time it runs out and you ask to insert next point. If you have a large data set, this gets out of control very fast and my above error was thrown.

Solution was just to be explicit (as usual) with memory allocation in the form of

vtkSmartPointer points = vtkPoints::New();  
points-\>Allocate(static\_cast(\*nx \* \*ny \* \*nz));

hope this helps someone else out.

---

<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:38pm UTC](https://discourse.paraview.org/t/inconsistent-memory-behavior-in-catalyst/2444/3 "2019-09-28T15:38:39Z")

</div>

The inconsistency was obviously coming from mpi processes of different sizes reaching this point at different times and throwing the error.
