View Issue Details

IDProjectCategoryView StatusLast Update
0026698Open CASCADEOCCT:Codingpublic2023-08-01 15:09
ReporterabvAssigned Toisn 
PrioritynormalSeverityminor 
Status assignedResolutionopen 
Target VersionUnscheduled 
Summary0026698: Coding - Avoid usage of non-guarded pointers to dynamically allocated memory
DescriptionIt is quite widespread in OCCT code, especially in modeling, to use plain C pointers to manage memory allocated dynamically, with explicit calls to new/malloc and delete/free. This is unsafe and bad practice, leading to memory leaks detected regularly (see e.g. #26616 as the most recent case), which must be eliminated. The natural and recommended way to deal with dynamically allocated memory is usage of smart pointers, typically OCCT Handles.

Note that before OCCT 7.0 it was not always easy to use Handles to classes not inheriting Standard_Transient, especially for fields of CDL classes, due to non-trivial actions required. Now it should be quite easy to wrap any class to NCollection_Shared<> template and then manipulate it by Handle.

There is however a potential issue when using Handles: they are not suitable for cases when memory is allocated via non-standard allocators (such as NCollection_IncAllocator). This is a problem to be investigated. Until it is resolved, std::shared_ptr<> with allocator argument could be used in such cases.
TagsNo tags attached.
Test case number

Relationships

parent of 0026915 closedbugmaster Open CASCADE Visualization - return Handle from Graphic3d_CView::FBOCreate() instead of a pointer 
related to 0029442 newabv Open CASCADE NCollection_Shared is unable to wrap classes without default constructor 
related to 0030603 closedbugmaster Community Memory Leaks in Geom_BSplineCurve 

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2015-09-17 10:17 abv New Issue
2015-09-17 10:17 abv Assigned To => kgv
2015-11-17 16:59 kgv Target Version 7.0.0 => 7.1.0
2015-11-23 13:22 kgv Relationship added parent of 0026915
2016-09-23 12:24 abv Assigned To kgv => ski
2016-09-23 12:24 abv Status new => assigned
2016-11-03 17:38 abv Target Version 7.1.0 => 7.2.0
2017-07-20 12:29 kgv Target Version 7.2.0 => 7.3.0
2018-01-18 17:13 msv Assigned To ski => isn
2018-01-22 18:02 isn Relationship added related to 0029442
2018-02-25 23:12 abv Target Version 7.3.0 => 7.4.0
2019-03-25 14:03 BenjaminBihler Relationship added related to 0030603
2019-07-10 19:27 abv Target Version 7.4.0 => 7.5.0
2020-09-11 15:34 utverdov Target Version 7.5.0 => 7.6.0
2021-09-09 23:10 kgv Target Version 7.6.0 => 7.7.0
2022-08-17 12:01 kgv Target Version 7.7.0 => 7.8.0
2023-08-01 15:09 dpasukhi Target Version 7.8.0 => Unscheduled