MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0026698Open CASCADE[OCCT] OCCT:Codingpublic2015-09-17 10:172018-02-25 23:12
Reporterabv 
Assigned Toisn 
PrioritynormalSeverityminor 
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version 
Target Version[OCCT] 7.4.0*Fixed in Version 
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
Attached Files

- Relationships
parent of 0026915closedbugmaster Visualization - return Handle from Graphic3d_CView::FBOCreate() instead of a pointer 
related to 0029442newabv NCollection_Shared is unable to wrap classes without default constructor 

-  Notes
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*


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker