View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006443VTK(No Category)public2008-02-26 04:252013-04-05 19:57
ReporterLevap 
Assigned ToDavid Partyka 
PrioritynormalSeveritycrashReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0006443: vtkFixedPointVolumeRayCastMapper throw std::bad_alloc
DescriptionI’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.
Additional InformationMy temporal solution was to change the two line of code like following:

this->ContiguousGradientNormal = new(std::nothrow) unsigned short [numSlices * sliceSize];
this->ContiguousGradientMagnitude = new(std::nothrow) unsigned char [numSlices * sliceSize];

It is also possible to use try/catch! My question is: what is the right strategy in this case?
TagsNo tags attached.
Project
Type
Attached Files

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0014922)
Ivan Macia (reporter)
2009-02-13 06:11

I can confirm this bug. Platform Windows XP SP2 2 Gb. RAM, VS2008, VTK 5.2.0.
Our code works with this patch, which is another possibility to the one shown above

Line 3069 of vtkFixedPointVolumeRayCastMapper.cxx

try
{
this->ContiguousGradientNormal = new unsigned short [numSlices * sliceSize];
}
catch(std::bad_alloc &)
{
this->ContiguousGradientNormal = 0;
}
try
{
this->ContiguousGradientMagnitude = new unsigned char [numSlices * sliceSize];
}
catch(std::bad_alloc &)
{
this->ContiguousGradientMagnitude = 0;
}
(0020135)
David Partyka (developer)
2010-04-12 10:10

Fixed on HEAD

/cvsroot/VTK/VTK/VolumeRendering/vtkFixedPointVolumeRayCastMapper.cxx,v <-- VolumeRendering/vtkFixedPointVolumeRayCastMapper.cxx
new revision: 1.50; previous revision: 1.49

VTK-5-6

/cvsroot/VTK/VTK/VolumeRendering/vtkFixedPointVolumeRayCastMapper.cxx,v <-- VolumeRendering/vtkFixedPointVolumeRayCastMapper.cxx
new revision: 1.49.4.1; previous revision: 1.49

ParaView-3-8

/cvsroot/ParaView3/ParaView3/VTK/VolumeRendering/vtkFixedPointVolumeRayCastMapper.cxx,v <-- VTK/VolumeRendering/vtkFixedPointVolumeRayCastMapper.cxx
new revision: 1.49.2.1; previous revision: 1.49

- Issue History
Date Modified Username Field Change
2008-02-26 04:25 Levap New Issue
2009-02-13 06:11 Ivan Macia Note Added: 0014922
2010-04-12 09:43 David Partyka Status backlog => tabled
2010-04-12 09:43 David Partyka Assigned To => David Partyka
2010-04-12 10:10 David Partyka Note Added: 0020135
2010-04-12 10:10 David Partyka Status tabled => @80@
2010-04-12 10:10 David Partyka Resolution open => fixed
2011-06-16 13:11 Zack Galbreath Category => (No Category)
2013-04-05 19:57 Berk Geveci Status customer review => closed


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker