[vtkusers] Problem with allocating memory for huge vtkImage and memory-fragmentation ?
David Gobbi
david.gobbi at gmail.com
Fri Apr 8 05:42:16 EDT 2011
There is a class called vtkImageDataStreamer that will pull the data
through the pipeline in smallish chunks, but it still stores the
result as a big, contiguous block. That's just the way that
vtkImageData stores images.
I've often lamented the fact that VTK does not have a simple filter
class that can store an image in a blocked data structure... i.e.
something similar to vtkImageDataStreamer, but instead of just pulling
the data through the pipeline block-by-block, it would also internally
store the image block-by-block instead of contiguously.
- David
2011/4/8 Ashika Umanga Umagiliya <aumanga at biggjapan.com>:
> Thanks Dženan,
> I am using MinGW and QT Opensource , so I am restricted to 32Bit.
> Before using vtkImageData , I used simple data-structure that allocates one
> memory block for each Z-Slice,(not a continuous block for the entire volume
> ).That helped me to avoid the memory fragmentation.
> Now I moved to vtkImagaData.Does it always allocate one
> large continuous block or is there any flag to change memory allocation
> scheme?
> Thanks
>
> 2011/4/8 Dženan Zukić <dzenanz at gmail.com>
>>
>> If you are close to the limit of the address space (like using 1GB block
>> on 32bit machine), it is a problem. However on 64bit system 4GB block is not
>> an issue.
>> Regards,
>> Dženan
>>
>> On Fri, Apr 8, 2011 at 07:42, Ashika Umanga Umagiliya
>> <aumanga at biggjapan.com> wrote:
>>>
>>> Greetings all,
>>> In our application we need to load large volumedata (2000x2000x1000 - 8
>>> bpp).
>>> In the "Vtk Users Guide" I came across following example to create
>>> vtkImageData.
>>> vtkImageData *id=vtkImageData::New();
>>> id->SetDimentions(nx,ny,nz);
>>> id->SetScalarTypeToUnsignedChar();
>>> id->SetNumberOfScalarComponents(1);
>>> id->AllocateScalars();
>>> //Fill in scalar values
>>> unsigned char *ptr=(unsigned char*)id->GetScalarPointer();
>>> for(int i=0;i<nx*ny*nx;i++){
>>> *ptr++=i;
>>> }
>>> Looking at the way assigning values and the method GetScalarPointer(); ,
>>> it seems that one block of memory is allocated for entire (nx*ny*nz) pixels.
>>> If it allocate entire memory block,would it cause problem with
>>> memory-fragmentation ?
>>> Or is there any other memory allocation schema ?
>>> Thanks in advance.
More information about the vtkusers
mailing list