]> OCCT Git - occt.git/commitdiff
0033138: [Foundation Classes] - NCollection_IncAllocator- Decrease the default block...
authorEugeny Maltchikov <eugeny.maltchikov@lpkf.com>
Mon, 12 Sep 2022 08:00:49 +0000 (11:00 +0300)
committersmoskvin <smoskvin@opencascade.com>
Mon, 31 Oct 2022 15:18:21 +0000 (18:18 +0300)
Set default memory block size for IncAllocator to 12KB to make sure the Low Fragmentation Heap is used for memory allocations on Windows platform.

dox/user_guides/foundation_classes/foundation_classes.md
src/NCollection/NCollection_IncAllocator.hxx

index 75ee0e41db575e9e97c8d565d4d49bddd0562488..83ac31168b56421a44061774b330ed75683a50fc 100644 (file)
@@ -1331,7 +1331,7 @@ Therefore if the user of *NCollection* does not specify any allocator as a param
 Nevertheless, it is possible to define a custom *Allocator* type to manage the memory in the most optimal or convenient way for this algorithm.
 
 As one possible choice, the class *NCollection_IncAllocator* is included.
-Unlike *NCollection_BaseAllocator*, the memory is allocated in big blocks (about 20kB) and the allocator keeps track of the amount of occupied memory.
+Unlike *NCollection_BaseAllocator*, the memory is allocated in big blocks (about 12kB) and the allocator keeps track of the amount of occupied memory.
 The method *Allocate* just increments the pointer to non-occupied memory and returns its previous value.
 Memory is only released in the destructor of *NCollection_IncAllocator*, the method *Free* is empty.
 If used properly, this Allocator can greatly improve the performance of specific algorithms.
index 08e4219f0bc9caa92422b63afc6101d43e335e65..7dfe560af565035f05d77da52caae95be7648458 100644 (file)
@@ -33,7 +33,12 @@ class Standard_Mutex;
  *  type "aligned_t". To  modify the size of memory  blocks requested from the
  *  OS,  use the parameter  of the  constructor (measured  in bytes);  if this
  *  parameter is  smaller than  25 bytes on  32bit or  49 bytes on  64bit, the
- *  block size will be the default 24 kbytes
+ *  block size will be the default 12 kbytes.
+ *
+ *  It is not recommended  to use memory blocks  larger than 16KB  on  Windows
+ *  platform  for the repeated operations  because  Low Fragmentation Heap  is
+ *  not going to be  used  for  these  allocations  which  may lead  to memory
+ *  fragmentation and the general performance slow down.
  *
  *  Note that this allocator is most suitable for single-threaded algorithms
  *  (consider creating dedicated allocators per working thread),
@@ -50,6 +55,12 @@ class NCollection_IncAllocator : public NCollection_BaseAllocator
   //! Constructor.
   //! Note that this constructor does NOT setup mutex for using allocator concurrently from different threads,
   //! see SetThreadSafe() method.
+  //! 
+  //! The default size of the memory blocks is 12KB.
+  //! It is not recommended to use memory blocks larger than 16KB on Windows
+  //! platform for the repeated operations (and thus multiple allocations)
+  //! because Low Fragmentation Heap is not going to be used for these allocations,
+  //! leading to memory fragmentation and eventual performance slow down.
   Standard_EXPORT NCollection_IncAllocator (size_t theBlockSize = DefaultBlockSize);
 
   //! Setup mutex for thread-safe allocations.
@@ -83,7 +94,8 @@ class NCollection_IncAllocator : public NCollection_BaseAllocator
   Standard_EXPORT void          Reset           (const Standard_Boolean
                                                  doReleaseMem=Standard_True);
 
-  static const size_t DefaultBlockSize = 24600;
+  //! Default size for the memory blocks - 12KB
+  static const size_t DefaultBlockSize = 12300;
 
  protected:
   struct         IBlock;