From 9fb8f3f1749c6e966e660e7a1d67e7db0bee130d Mon Sep 17 00:00:00 2001 From: abv Date: Thu, 15 Mar 2018 10:39:55 +0300 Subject: [PATCH] 0029412: Huge Memory leak since I upgraded to OC 6.9.0 Added non-regression test bugs vis bug29412 --- src/QABugs/QABugs_19.cxx | 47 ++++++++++++++++++++++++++++++++++++++++ tests/bugs/vis/bug29412 | 27 +++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 tests/bugs/vis/bug29412 diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index 9484db55bd..88ad638429 100644 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -5333,6 +5333,52 @@ static Standard_Integer OCC28310 (Draw_Interpretor& /*theDI*/, Standard_Integer return 0; } +// repetitive display and removal of multiple small objects in the viewer for +// test of memory leak in visualization (OCCT 6.9.0 - 7.0.0) +static Standard_Integer OCC29412 (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb, const char** theArgVec) +{ + Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); + if (aCtx.IsNull()) + { + std::cout << "Error: no active view.\n"; + return 1; + } + + const int aNbIters = (theArgNb <= 1 ? 10000 : Draw::Atoi (theArgVec[1])); + int aProgressPrev = -1; + for (int m_loopIndex = 0; m_loopIndex < aNbIters; m_loopIndex++) + { + gp_Pnt pos; + gp_Vec dir(0, 0,1); + + gp_Ax2 center (pos, dir); + gp_Circ circle (center, 1); + Handle(AIS_Shape) feature; + + BRepBuilderAPI_MakeEdge builder( circle ); + + if( builder.Error() == BRepBuilderAPI_EdgeDone ) + { + TopoDS_Edge E1 = builder.Edge(); + TopoDS_Shape W2 = BRepBuilderAPI_MakeWire(E1).Wire(); + feature = new AIS_Shape(W2); + aCtx->Display (feature, true); + } + + aCtx->CurrentViewer()->Update(); + ViewerTest::CurrentView()->FitAll(); + aCtx->Remove (feature, true); + + const int aProgress = (m_loopIndex * 100) / aNbIters; + if (aProgress != aProgressPrev) + { + std::cerr << aProgress << "%\r"; + aProgressPrev = aProgress; + } + } + return 0; +} + //======================================================================== //function : Commands_19 //purpose : @@ -5471,5 +5517,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) { theCommands.Add("OCC28310", "OCC28310: Tests validness of iterator in AIS_InteractiveContext after an removing object from it", __FILE__, OCC28310, group); + theCommands.Add("OCC29412", "OCC29412 [nb cycles]: test display / remove of many small objects", __FILE__, OCC29412, group); return; } diff --git a/tests/bugs/vis/bug29412 b/tests/bugs/vis/bug29412 new file mode 100644 index 0000000000..b0038e8d81 --- /dev/null +++ b/tests/bugs/vis/bug29412 @@ -0,0 +1,27 @@ +puts "# ===================================================================" +puts "# 0029412: Huge Memory leak since I upgraded to OC 6.9.0" +puts "# ===================================================================" +puts "" + +pload VISUALIZATION +vcaps -vsync 0 +vinit View1 +vglinfo + +OCC29412 100 ;# just to initialize + +meminfo +vmemgpu + +set heap_before [meminfo heap] +OCC29412 +set heap_after [meminfo heap] + +meminfo +vmemgpu + +# check that memory increase is moderate: can be up to 75 KiB on Debian; +# note that the leak in OCCT 6.9.0 - 7.0.0 was ~ 19 MiB +if { $heap_after - $heap_before > 100 * 1024 } { + puts "Error: memory leak of [expr ($heap_after - $heap_before) / 1024] KiB" +}