vtkFixedPointVolumeRayCastMapper throw std::bad_alloc
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
I’m using vtkFixedPointVolumeRayCastMapper for volume rendering and in some cases my application crashes or freezes. The behavior was verified on two machines: Windows XP 32bit SP2 with 1 GB RAM and Windows 64bit XP SP1 with 4 GB RAM. Compiler: Visual Studio 2008 Prof. The volume I used was (512x512x512x4) = 512 MB big.
After a little debug orgy I found out that the problem lies within the memory allocation during in the function ComputeGradients(). Below are the lines from code (line 3061):
this->ContiguousGradientNormal = new unsigned short [numSlices * sliceSize]; this->ContiguousGradientMagnitude = new unsigned char [numSlices * sliceSize];
During the shading computation the algorithm tries to allocate additional contiguous memory: (512x512x512x2) = 256 MB and (512x512x512x1) = 128 MB. In same cases the operational system fails to provide so much free contiguous memory, so the “new” operator fails and throw an exception (std::bad_alloc). The function and the gradient computation will be aborted -> memory leaks and inconsistency in program flow arises.