1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0027490: BRepMesh: Reduce number of memory allocations

1) Reduce the number of calls to malloc by grouping requests to larger blocks. To achieve this goal, the following ways are used:

- Containers of types sequence, list and map are initialized with an instance of NCollection_IncAllocator, at this taking care of the time of life of allocated objects, so that not to occupy huge amount of memory.

- Allocation of several arrays having the same and short life time is changed so that to allocate a buffer array of necessary size and to place arrays in this buffer.

2) In BRepMesh_FastDiscretFace, optimize the function filterParameters so that to avoid excess memory allocations.

3) In NCollection_CellFilter, change declaration of the method Reset to accept array by reference rather than by value.

4) Add Allocator() method in map, sequence and vector collection classes by analogy with list collection.

5) Correct the size of block for IncAllocator for x64 platform. In order free-ed block to be returned to the system its size should be at least 1024K on x64 and 512K on x86. This allows to retain free virtual space almost to the state before algorithm run.

6) Decrease amount of memory zeroed by calloc. For that, reduce theIncrement parameter of the embedded vectors of the classes NCollection_UBTreeFiller and BRepMesh_VertexInspector to default value 256.

7) Avoid computing bounding box when not necessary (if no relative deflection is used)

8) Cycles by wires of face using TopExp_Explorer are converted to use TopoDS_Iterator instead.

9) BRepMesh_FastDiscret::Add optimized to avoid storing sequences of faces and edges

10) The tests "mesh standard_* W7" are corrected to accept the new behavior. Earlier the following error took place:
Not connected mesh inside face 9
{12 13}
Now this error was replaced with another one:
free nodes (in pairs: face / node):
{9 12}
Actually it is not a regression, rather improvement, if we look at the snapshot.

11) Change other test cases to their actual state.
This commit is contained in:
msv
2016-05-04 04:12:28 +03:00
parent f02e43eb35
commit e1c1b6b9f4
26 changed files with 178 additions and 149 deletions

View File

@@ -149,6 +149,10 @@ public:
//! Statistics
Standard_EXPORT void Statistics(Standard_OStream& S) const;
//! Returns attached allocator
const Handle(NCollection_BaseAllocator)& Allocator() const
{ return myAllocator; }
protected:
// -------- PROTECTED METHODS -----------

View File

@@ -102,6 +102,10 @@ public:
Standard_Boolean IsEmpty () const {return (mySize == 0);}
Standard_Integer Length () const {return mySize;}
//! Returns attached allocator
const Handle(NCollection_BaseAllocator)& Allocator() const
{ return myAllocator; }
protected:
// Methods PROTECTED
//

View File

@@ -212,6 +212,12 @@ public: //! @name public API
}
}
//! Returns attached allocator
const Handle(NCollection_BaseAllocator)& Allocator() const
{
return myAllocator;
}
protected: //! @name Protected fields
Handle(NCollection_BaseAllocator) myAllocator;

View File

@@ -158,7 +158,7 @@ public:
}
//! Clear the data structures and set new cell sizes and allocator
void Reset (NCollection_Array1<Standard_Real> theCellSize,
void Reset (NCollection_Array1<Standard_Real>& theCellSize,
const Handle(NCollection_IncAllocator)& theAlloc=0)
{
myCellSize = theCellSize;

View File

@@ -68,7 +68,7 @@ template <class TheObjType, class TheBndType> class NCollection_UBTreeFiller
NCollection_UBTreeFiller (UBTree& theTree,
const Handle(NCollection_BaseAllocator)& theAlloc=0L,
const Standard_Boolean isFullRandom = Standard_True)
: myTree(theTree), mySeqPtr(1000, theAlloc),
: myTree(theTree), mySeqPtr(256, theAlloc),
myRandGen (5489u /* == std::mt19937::default_seed, not defined in older environments, e.g, on Debian 6.0 with GCC 4.4.5 */),
myIsFullRandom (isFullRandom) {}