|Description||It 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.