MantisBT - Open CASCADE
View Issue Details
0021142Open CASCADE[OCCT] OCCT:Samplespublic2009-05-28 19:232020-09-11 16:45
[OCCT] 6.7.0 
[OCCT] 7.6.0* 
0021142: Memory leaks using standard OCCT samples
Minor problem with memory management in OCCT selection logic & sufficient
problems in MFC-based sample GUI(TopologyPrimitives).
Customer description:
"I clicked on Box repeatedly and task manager showed memory increasing with each
click. Also when I clicked through all the options memory kept increasing
continuously. If I understand Memory optimization correctly, then application
should not allocate new memory block with each click on same icon but should use
memory from free list. Same is the problem with import-export sample when I keep
on importing same file and close the window repeatedly. This increases the
memory continuously. This is true with and without memory optimization i.e.
MMGT_OPT= 1 and 0 respectively."

OCN expert (SAN) analysis report:
"Here some new analysis results based on TopologicalPrimitives sample:
- When an AIS_Shape instance is removed from the interactive context, and this
is not the presentation that has been highlighted with the mouse most recently,
both the AIS_Shape and the underlying TopoDS_TShape are correctly destroyed
after removing.
- When an AIS_Shape instance is removed from the interactive context, and this
is the presentation that has been highlighted with the mouse most recently, the
AIS_Shape instance is destroyed but the underlying TopoDS_TShape is not, due to
one reference kept inside OCCT selection mechanism (something like "last
highlighted entity owner"). However, this last reference is freed when the user
highlights something in the viewer again.
- Re-creating primitives in the sample multiple times do not lead to virtual
memory growth on my workstation.

Thus my conclusion is as follows:
there is a minor problem with memory management in OCCT selection logic, but it
is unlikely to result in significant memory leaks. The memory leaks reported by
the customer are therefore located somewhere outside OCCT visualization,
probably somewhere in MFC-based sample GUI. Visual Studio debugger reports
memory leaks even if the sample is started and then closed immediately without
any user actions."
No tags attached.
related to 0020627closed epa Memory leaks in BRepMesh 
Issue History
2009-05-29 19:03szyCC => INV
2009-06-09 16:21sanCC => abv
2009-06-09 16:22sanCC => szy
2009-06-09 16:43szyCC => san
2011-08-02 11:24bugmasterCategoryOCCT:VIZ => OCCT:Visualization
2012-10-26 10:01szyAssigned Tobugmaster => san
2012-10-26 10:01szyStatusnew => assigned
2012-10-26 10:01szyFixed in VersionEMPTY =>
2012-10-26 10:01szyTarget Version => 6.6.0
2012-10-26 10:01szyDescription Updatedbug_revision_view_page.php?rev_id=4428#r4428
2013-02-26 18:20sanTarget Version6.6.0 => 6.7.0
2013-12-12 11:13sanRelationship addedrelated to 0020627
2013-12-12 11:17sanNote Added: 0027180
2013-12-12 11:17sanAssigned Tosan => apn
2013-12-12 11:17sanStatusassigned => feedback
2013-12-17 11:28sanStatusfeedback => assigned
2013-12-17 11:28sanCategoryOCCT:Visualization => OCCT Release:MFC
2013-12-17 11:28sanSummaryMemory leaks using standard sample TopologyPrimitives => Memory leaks using standard OCCT samples
2013-12-17 12:58apnNote Added: 0027230
2013-12-17 12:58apnAssigned Toapn => san
2013-12-17 12:58apnProduct Version => 6.7.0
2013-12-17 12:58apnTarget Version6.7.0 => 6.7.1
2014-01-11 11:59abvCategoryOCCT Release:MFC => OCCT Release:Samples
2014-01-11 12:02abvCategoryOCCT Release:Samples => OCCT:Samples
2014-04-04 18:32abvTarget Version6.7.1 => 6.8.0
2014-09-26 11:05abvTarget Version6.8.0 => 7.1.0
2016-11-09 11:31abvNote Added: 0060081
2016-11-09 11:31abvAssigned Tosan => ski
2016-11-09 11:31abvStatusassigned => feedback
2016-11-09 17:15skiNote Added: 0060132
2016-11-09 17:15skiAssigned Toski => abv
2016-11-09 17:17skiNote Added: 0060133
2016-11-09 17:40abvTarget Version7.1.0 => 7.2.0
2017-08-15 12:59abvTarget Version7.2.0 => 7.4.0
2018-02-08 19:02abvNote Added: 0073891
2019-07-19 19:23apnTarget Version7.4.0 => 7.5.0
2020-09-11 16:45utverdovTarget Version7.5.0 => 7.6.0*

2013-12-12 11:17   
Dear apn,

Can you please try to import and close the same CAD model multiple times (10-20), according to the initial complaint of the customer, and check if there is any memory growth, according to Windows task manager?
2013-12-17 12:58   
Import (new Document - Import STEP) and closing (Close current Document) the same CAD model multiple time in ImportExport MFC Sample lead to memory growth (can be seen in Windows Task Manager).
2016-11-09 11:31   
Sergey, please check current status of this issue (repeat the test reported in the last note)
2016-11-09 17:15   
Dear abv,

I have checked mfc ImportExport sample from current state of master with next scenario:
step 1: run the sample
step 2: new Document
step 3: import STEP/BREP shape
step 4: File -> Close
step 5: repeat steps 2-4 several time (10)

Result: windows task manager shows grown of memory allocated by the sample. (from 21K to 113K for 10 repeats in my case)
2016-11-09 17:17   
Note that shape was the same for all 10 repeats.
I have tried with both STEP and BREP formats.
2018-02-08 19:02   
Attempt to open STEP file CraneASM.stp (from GrabCAD) kills Qt ImportExport sample in OCCT 7.2.0. MFC ImportExport sample shows the model but dies upon closing the document window.