[vtkusers] vtk metaImageWriter bad allocation

Kyle Lutz kyle.lutz at kitware.com
Thu May 24 16:01:45 EDT 2012


On Thu, May 24, 2012 at 1:09 PM, Fabian Torres <fabian.trobles at gmail.com> wrote:
> Hi.
>
> I`m trying to save a 3-D vtkImageData to a .mhd and .raw file with a
> vtkMetaImageWriter
>
> vtkSmartPointer<vtkMetaImageWriter> writer =
> vtkSmartPointer<vtkMetaImageWriter>::New();
> writer->SetFileName(saveMhdFile);
>
> writer->SetRAWFileName(saveRawFile);
>
> writer->SetInputConnection(volumeData->GetProducerPort());
> writer->Write()
>
>
> When I save a volume of size 603x548x394 I am able to save the file without
> problem.
>
> But when I try to save a bigger volume of size 584x999x494 I get an
> exception. After using try/catch in the Write() method
>
>
> try{
>
> writer->Write();
>
> }catch( exception& e){
>
> std::cout<<e.what()<<std::endl;
>
> }
>
> I receive "Bad allocation" message.
>
> What does this mean? How can I fix this problem?

There error means that new failed to allocate enough memory for your data.

Perhaps try on a 64 bit machine or a machine with more memory.
Otherwise, fixing it may require updating the vtkMetaImageWriter class
to allocate blocks of memory in smaller chunks.

-kyle



More information about the vtkusers mailing list