[vtkusers] tkImageData - vtkUnsignedCharArray: Unable to allocate 768951260 elements of size 1 bytes.

vacingforo vacingforo at gmail.com
Tue Jul 17 09:32:50 EDT 2018


I have the following  code piece :

    vtkSmartPointer<vtkImageData> image =
    image->SetExtent(-1, dim[0] + 1, -1 , dim[1] + 1, 0, dim[2] - 1);
    image->AllocateScalars(VTK_UNSIGNED_CHAR, 1);

    vtkIdType count = image->GetNumberOfPoints();
    for (vtkIdType i = 0; i < count; ++i)
        image->GetPointData()->GetScalars()->SetTuple1(i, white);

I get the following error when i process a polydata from vtp file of only
10K(It does not happen with smaller polydata). 

ERROR: In C:\VTK-7.1.1\Common\Core\vtkGenericDataArray.txx, line 394
vtkUnsignedCharArray (0xcc2ac80): Unable to allocate 768951260 elements of
size 1 bytes. 
what():  std::bad_alloc

It was compiled in mingw 32 bits in Windows 10.

for more details check small application and a Windbg results in the
following link:


The memory seems to be ok but I don't know why it does not work.

Best regards,


Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html

More information about the vtkusers mailing list