[vtkusers] Troubles with very large array size

Benoit Scherrer benoitscherrer at gmail.com
Tue Jul 19 16:35:52 EDT 2011


Hi,

I m working with pretty large vtkPolyData on a x64 machine
(more than 201 326 592 points, vtk 5.6.1)

When i try to add a new point (201 326 593th) with InsertNextPoint it calls
the
vtkDataArrayTemplate<>::ResizeAndExtend  and
tries to allocate 402 653 181 points, which is just impossible.
(allocation of floats, 3 floats per point)

I understand that for small arrays it is good to allocate each time 'double'
the memory
when resizing an array but when we reach very large dataset, it seems a
little bit too much, isn'it ?

Do you plan to modify that ?

Thanks a lot!
Benoit

PS: i extracted the code of vtkDataArrayTemplate  :

------------------------------- CODE
of vtkDataArrayTemplate -------------------------------

template <class T>T* vtkDataArrayTemplate<T>::ResizeAndExtend(vtkIdType sz)
{
  T* newArray;
  vtkIdType newSize;

  if(sz > this->Size)
    {
    // Requested size is bigger than current size.  Allocate enough
    // memory to fit the requested size and be more than double the
    // currently allocated memory.
    newSize = this->Size + sz;                      //
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< SEE HERE
    }
  else if (sz == this->Size)
    {
    // Requested size is equal to current size.  Do nothing.
    return this->Array;
    }
  else
    {
    // Requested size is smaller than current size.  Squeeze the
    // memory.
    newSize = sz;
    this->DataChanged();
    }

  // Wipe out the array completely if new size is zero.
  if(newSize <= 0)
    {
    this->Initialize();
    return 0;
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110719/91acfd25/attachment.htm>


More information about the vtkusers mailing list