#326 Memory allocation problem with trimmed NURBS

fatal/crash
open
Paul Gregory
8
2012-09-20
2008-08-04
Chris Foster
No

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.

Discussion

  • Chris Foster
    Chris Foster
    2008-08-04

    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.

     
  • Michel Joron
    Michel Joron
    2008-10-17

    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.

     
  • Michel Joron
    Michel Joron
    2008-10-17

    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());

        TqInt SplitCount = static_cast<TqUint>( max(MaxEyeSplits, 1.0f) );
    
        return ( SplitCount * cSegments );
    

    }

     


Anonymous


Cancel   Add attachments