DiscussionsIssue archiveOCCT:Foundation Classes

Archived issue #0022816

Enhancement request: new[]/delete[] operators should be redefined to use OCC allocation

CommunityOCCT:Foundation Classesclosed9 public notes

Search issues

Description

Post from the Forum - http://www.opencascade.org/org/forum/thread_22253/.
RLN contribution.
"The new[] operator (e.g. used in arrays/vectors) is not redefined in OCC classes and thus does not take advantage of OCC memory allocation mechanism (Standard::Allocate(), Standard::Free()). Instead it defaults to standard new/delete [] operators.

Example:
TopTools_Array1OfShape anArray (1, 10);
will underneath call new TopoDS_Shape[10] which will NOT call Standard::Allocate().

We discussed this issue with ABV a while ago, so maybe there is already a bug registered. In this case, please just post an ID here for future tracking."

Public activity

9 archived notes

Participants are labeled by their role within this record.

01Commenter 1
I suggest that along with this correction we pack all OCCT-specific declarations of new / delete into a macro (to be defined in Standard_Macro.hxx) and use it in all relevant classes.
02Commenter 2
Operators new[]/delete[] redefined in the macro OVERRIDE_MEMORY_OPERATORS (src/Standard/Standard_Macro.hxx) to use OCC allocation.

bug fixed in the branch: http://svn/svn/occt/branches/OCC22815

Dear Andrey,
Please review.
03Commenter 1
General comment:
Please think of a general policy of naming macros to ensure consistency and easy attribution to Open CASCADE. Often, macros are named with product prefix and underscores, for instance this could be:

__OCC_OVERRIDE_MEMORY_OPERATORS
04Commenter 4
See review remarks in #0022815
05Commenter 3
Roman is right, macros used in installed header files should be prefixed by OCC_ to avoid name clashes. But please do not use leading underscores, such names are reserved in C++.
06Commenter 6
Sure these names are reserved, thanks for commenting. We shall consider giving common prefix to macros in the future; in this particular fix I prefer to stick to using currently adopted pattern.
07Commenter 7
Dear Andrey,

check notes in #0022815
08Commenter 4
Workbench apn-OCC22815-occt/products was successfully tested in #0022815
09Commenter 2
Problem was solved by fix for issue 22815

Related records