Memory leak


I have set the environment variable MMGT_OPT to 0 so that OpenCascade's optimized memory manager is disabled. After this I used a memory leak checking tool to my OpenCascade-based code and loaded a STEP model. After exiting there are many memory leaks detected such as the following:

-a block @0x21133820, 48 bytes, new operator called from operator new[](); file f:\sp\vctools\crt_bld\self_x86\crt\src\newaop.cpp; line 7 + 4 bytes; module TKMath.dll; 0x4B03E97 : lReq:12784992
+find pointers to this block
-call stack during allocation
caller(1): operator new[](); file f:\sp\vctools\crt_bld\self_x86\crt\src\newaop.cpp; line 7 + 9 bytes; module TKMath.dll; 0x4B03E9C
caller(2): TColgp_Array1OfPnt::TColgp_Array1OfPnt(); file c:\opencascade6.2.0\ros\inc\tcollection_array1.gxx; line 18 + 101 bytes; module TKMath.dll; 0x4AE8AA5
caller(3): TColgp_HArray1OfPnt::TColgp_HArray1OfPnt(); file c:\opencascade6.2.0\ros\inc\tcollection_harray1.gxx; line 15 + 101 bytes; module TKMath.dll; 0x4AEF955
caller(4): Geom_BSplineCurve::Geom_BSplineCurve(); file c:\opencascade6.2.0\ros\src\geom\geom_bsplinecurve.cxx; line 197 + 40 bytes; module TKG3d.dll; 0x4C429F0
caller(5): Geom_BSplineCurve::Copy(); file c:\opencascade6.2.0\ros\src\geom\geom_bsplinecurve.cxx; line 155 + 93 bytes; module TKG3d.dll; 0x4C426BD
caller(6): Geom_Geometry::Transformed(); file c:\opencascade6.2.0\ros\src\geom\geom_geometry.cxx; line 144 + 23 bytes; module TKG3d.dll; 0x4C66EC0
caller(7): BRepTools_TrsfModification::NewCurve(); file c:\opencascade6.2.0\ros\src\breptools\breptools_trsfmodification.cxx; line 97 + 36 bytes; module TKBRep.dll; 0x10064547
caller(8): BRepTools_Modifier::Rebuild(); file c:\opencascade6.2.0\ros\src\breptools\breptools_modifier.cxx; line 276 + 67 bytes; module TKBRep.dll; 0x1004FCDB
+dump bytes
+dump dwords

I am hesitant to "fix" this leak and other leaks like it because I'm still not sure if it really is a true leak even though OpenCascade's memory manager is not being used. Can anyone tell me if this is a legitimate leak or not?


Bearloga's picture

Simple way to recognize a true leak is to put the code in loop and see how much memory the app eats. :-)

Andrey Betenev's picture

It is typical that memory checking tools (like Purify) report false memory leaks in TCollection_Array's, because these objects remember not the same pointer as allocated, but shifted one (this depends on the first index of the array).