Inconsistent memory behavior in Catalyst

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 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.

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.


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