From: kgv Date: Sun, 3 Mar 2019 07:58:41 +0000 (+0300) Subject: 0027871: VIS - Possible memory leak in viewers in virtual windows mode X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCR27871_1;p=occt-copy.git 0027871: VIS - Possible memory leak in viewers in virtual windows mode Disable vtkTimerLog within test checking for memory leaks. --- diff --git a/adm/genproj.tcl b/adm/genproj.tcl index 9039a5a2a1..dd3309eec0 100644 --- a/adm/genproj.tcl +++ b/adm/genproj.tcl @@ -1411,7 +1411,7 @@ proc osutils:vtkCsf {{theOS ""}} { } } - set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \ + set aLibArray [list vtkCommonCore vtkCommonSystem vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \ vtkRenderingOpenGL vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle] # Additional suffices for the libraries diff --git a/src/IVtkDraw/IVtkDraw.cxx b/src/IVtkDraw/IVtkDraw.cxx index 18ccdb92d8..148259958f 100644 --- a/src/IVtkDraw/IVtkDraw.cxx +++ b/src/IVtkDraw/IVtkDraw.cxx @@ -85,11 +85,8 @@ #include #include -// prevent disabling some MSVC warning messages by VTK headers -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4244) -#endif +// prevent disabling some MSVC warning messages by VTK headers +#include #include #include #include @@ -111,6 +108,7 @@ #include #include #include +#include #include #ifndef _WIN32 #include @@ -123,9 +121,7 @@ #include #include #endif -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include // workaround name conflicts with OCCT methods (in class TopoDS_Shape for example) #ifdef Convex @@ -407,6 +403,37 @@ static Standard_Integer VtkInit (Draw_Interpretor& , return 0; } +//================================================================ +// Function : VtkTimerLog +// Purpose : +//================================================================ +static Standard_Integer VtkTimerLog (Draw_Interpretor& , + Standard_Integer theNbArgs, + const char** theArgVec) +{ + TCollection_AsciiString aVal; + if (theNbArgs == 2) + { + aVal = theArgVec[1]; + aVal.LowerCase(); + } + if (aVal == "1" + || aVal == "on") + { + vtkTimerLog::LoggingOn(); + } + else if (aVal == "0" + || aVal == "off") + { + vtkTimerLog::LoggingOff(); + } + else + { + std::cout << "Syntax error: wrong arguments\n"; + return 1; + } + return 0; +} //================================================================ // Function : CreateActor @@ -1169,6 +1196,11 @@ void IVtkDraw::Commands (Draw_Interpretor& theCommands) "\n\t\t: Creates the Vtk window", __FILE__, VtkInit, group); + theCommands.Add("ivtktimerlog", + "ivtktimerlog {on|off}\n" + "\n\t\t: Enables/disables VTK timer profiler", + __FILE__, VtkTimerLog, group); + theCommands.Add("ivtkdisplay", "ivtkdisplay usage:\n" "ivtkdisplay name1 name2 ..." @@ -1232,7 +1264,6 @@ void IVtkDraw::Commands (Draw_Interpretor& theCommands) __FILE__, VtkBackgroundColor, group); } - //================================================================ // Function : Factory // Purpose : diff --git a/src/TKIVtkDraw/EXTERNLIB b/src/TKIVtkDraw/EXTERNLIB index bf40a7d852..8d8f57e78a 100644 --- a/src/TKIVtkDraw/EXTERNLIB +++ b/src/TKIVtkDraw/EXTERNLIB @@ -22,3 +22,4 @@ vtkImagingCore vtkInteractionStyle vtkRenderingOpenGL vtkRenderingFreeTypeOpenGL +vtkCommonSystem diff --git a/tests/v3d/ivtk/bug27567 b/tests/v3d/ivtk/bug27567 index 5d110ad008..7177acb87b 100644 --- a/tests/v3d/ivtk/bug27567 +++ b/tests/v3d/ivtk/bug27567 @@ -1,66 +1,47 @@ -puts "For OCC27871: Possible memory leak in viewers in virtual windows mode" -puts "For OCC27871: Use 120 kb tolerance for checktrend because of leak on Linux in virtual windows mode" puts "============" -puts "OCC27567" +puts "0027567: Visualization - possible memory leaks due to use of plain pointers in IVTK" puts "============" puts "" -####################################################################### -# Visualization - possible memory leaks due to use of plain pointers -# in IVTK -####################################################################### -ivtkinit +psphere s 10 15 80 +box b1 5 5 -5 +box b2 -5 -5 -5 +ptorus t 10 3 +compound s b1 b2 t cc +unset s +unset b1 +unset b2 +unset t +incmesh cc 1 +ivtkinit +ivtktimerlog 0 dlog off -# Create i_max number of shapes -set i_max 15 - -set listmem {} -for {set i 1} {${i} <= ${i_max}} {incr i} { - - psphere s 10 15 80 - box box1 5 5 -5 - box box2 -5 -5 -5 - ptorus t 10 3 - - compound s box1 box2 t b$i - - unset s - unset box1 - unset box2 - unset t - - # Display the j-th shape - ivtkdisplay b$i - - # Display shaded +proc doCycle { theI } { + # display shaded/wireframe + ivtkdisplay cc ivtksetdispmode 1 - - # Display wired ivtksetdispmode 0 - - # Select the shape + + # select/unselect ivtkselect 200 200 - - # Deselect the shape ivtkselect 0 0 - - # Highlight the shape + + # highlight/unhighlight ivtkmoveto 200 200 - - # Unhighlight the shape ivtkmoveto 50 50 - - # Hide the shape - ivtkerase b$i - - # Remove the shape presentation from memory - ivtkremove b$i - - unset b$i - lappend listmem [meminfo h] - checktrend $listmem 0 120000 "Memory leak detected" + # hide and remove + ivtkerase cc + ivtkremove cc } +# Create i_max number of shapes +set i_max 15 +set listmem {} +for {set i 1} {${i} <= ${i_max}} {incr i} { + doCycle $i + lappend listmem [meminfo h] + checktrend $listmem 0 1 "Memory leak detected" +}