Memory allocation problem with trimmed NURBS
Brought to you by:
ltatkinson,
pgregory
The attached RIB causes a std::bad_alloc exception to be thrown with the following error:
ERROR: std::exception encountered in RiNuPatchV: St9bad_alloc
Examining the memory usage indicates a lot of allocation and deallocation before the crash, with hundereds of Mb in play.
Commenting out the TrimCurves removes the problem and reduces the memory usage to an extremely reasonable level - about 15Mb.
trimmed NURBS problem
Logged In: YES
user_id=1086736
Originator: YES
Some messing about in gdb reveals that the allocation error occurs at trimcurve.cpp:131 in Aqsis::CqTrimLoop::Prepare() - the cPoints parameter is absolutely huge: cPoints == 1502807424.
The root of the problem is CqSurfaceNURBS::TrimDecimation( const CqTrimCurve& Curve )
I realize the local variable SplitCount contains a very big number once multiplied by
cSegments gives an even larger number.
I don't know exactly why but if SplitCount was the number of max eyessplit it will be probably good enough anyway
therefore even the for loop to compute SplitCount won't be necessary.
Maybe if it is the max number of splits * number of control points; will it be good enough ?
TqInt CqSurfaceNURBS::TrimDecimation( const CqTrimCurve& Curve )
{
TqInt cSegments = Curve.cVerts();
TqFloat MaxEyeSplits = 10.0;
const TqInt* poptEyeSplits = QGetRenderContext() ->poptCurrent()->GetInt
egerOption( "limits", "eyesplits" );
if ( poptEyeSplits != 0 )
MaxEyeSplits = static_cast<TqFloat>(poptEyeSplits[ 0 ]);
MaxEyeSplits /= sqrt(AdjustedShadingRate());
}