[vtkusers] How to overcome the memory allocation problem.

David Gobbi david.gobbi at gmail.com
Mon Nov 12 15:03:33 EST 2012


On Mon, 12 Nov 2012 11:39:26 -0800, matheus_viana said:

>I'm try to open an image sequence that is really big. Kind of 1000x1000x4000
>unsigned char. First I tried to load only the first 100 slices of this stack
>that corresponds to about 500Mb. Even thus I was not able to do load it
>because I got a bad alloc error.
>
>How do you guys handle with this kind of problem? Is there any vtk class to
>deal with this?
>
>I'm running on Win32 =/

Well, yeah, a 4GB image suggests a 64-bit OS.

Also, for images this size, you should definitely look into using mmap.
Basically, mmap can return a pointer to a block of virtual memory associated
with the file, and vtkImageImport can then use that pointer to map the file to
a vtkImageData.  The load times with mmap are many times faster than with
a file reader.

 - David



More information about the vtkusers mailing list