PCL
|
A block allocator class that uses the standard new and delete operators. More...
#include <StandardAllocator.h>
Public Member Functions | |
StandardAllocator (bool fastGrowth=true, bool canShrink=true) | |
StandardAllocator (const StandardAllocator &)=default | |
void * | AllocateBlock (size_type size) |
size_type | BlockSize (size_type n) const |
void | DeallocateBlock (void *p) |
void | DisableFastGrowth (bool disable=true) |
void | DisableShrinking (bool disable=true) |
void | EnableFastGrowth (bool enable=true) |
void | EnableShrinking (bool enable=true) |
bool | IsFastGrowthEnabled () const |
bool | IsShrinkingEnabled () const |
size_type | MaxSize () const |
size_type | ReallocatedBlockSize (size_type currentSize, size_type newSize) const |
StandardAllocator is a block allocator class. It is used by default for all container classes in PCL. It defines default block sizing and growing strategies that work efficiently in most cases.
For a complete description of block allocators and their fundamental role in PCL, read the documentation for the Allocator class.
Definition at line 81 of file StandardAllocator.h.
|
inline |
Constructs a StandardAllocator object.
fastGrowth | Whether to enable the fast block size growing policy for this allocator. |
canShrink | Whether to enable the block shrinking policy for this allocator. |
See the IsFastGrowthEnabled() and IsShrinkingEnabled() member functions for more information on block allocation policies.
Definition at line 97 of file StandardAllocator.h.
|
default |
Copy constructor.
|
inline |
Custom allocation routine. Allocates a contiguous memory block of the specified size in bytes, and returns the address of the first byte in the newly allocated block.
Definition at line 195 of file StandardAllocator.h.
Returns the size in bytes of an allocation block suitable for storage of at least n bytes.
See IsFastGrowthEnabled() for more information about block size growing policies in StandardAllocator.
Definition at line 135 of file StandardAllocator.h.
|
inline |
Custom deallocation routine. Deallocates a previously allocated contiguous memory block that begins at the specified location p.
Definition at line 210 of file StandardAllocator.h.
|
inline |
Disables the fast block size growing policy for StandardAllocator.
See IsFastGrowthEnabled() for more information about block size growing policies.
Definition at line 263 of file StandardAllocator.h.
|
inline |
Disables a block shrinking policy for StandardAllocator.
See IsShrinkingEnabled() for more information about block shrinking policies.
Definition at line 307 of file StandardAllocator.h.
|
inline |
Enables the fast block size growing policy for StandardAllocator.
See IsFastGrowthEnabled() for more information about block size growing policies.
Definition at line 250 of file StandardAllocator.h.
|
inline |
Enables a block shrinking policy for StandardAllocator.
See IsShrinkingEnabled() for more information about block shrinking policies.
Definition at line 294 of file StandardAllocator.h.
|
inline |
Returns true iff fast growth is currently enabled for this allocator.
When fast growth is enabled, StandardAllocator provides block sizes that grow exponentially above 64 bytes: 128, 256, 512, 1K, ... 512K, 1M, and so on. This maximizes speed of dynamic allocation operations, but at the cost of more memory wasted by partially used blocks in contiguous-storage containers such as Array or String.
With fast growth disabled, StandardAllocator follows a more conservative scheme to provide reasonable block sizes while preventing excessive memory consumption. For block sizes below 64 kilobytes, blocks grow exponentially to improve efficiency of allocation for small objects, such as short strings. For blocks larger than 64K, block sizes grow by constant chunks of 4K.
The fast block size growing policy is always enabled by default.
Definition at line 237 of file StandardAllocator.h.
|
inline |
Returns true iff block shrinking is currently enabled for this allocator.
When block shrinking is enabled, StandardAllocator allows size reductions for reallocated blocks in calls to the ReallocatedBlockSize(). When block shrinking is disabled, already allocated blocks can only be reallocated with increased lengths.
The block shrinking policy is always enabled by default.
Definition at line 281 of file StandardAllocator.h.
|
inline |
Returns the size in bytes of the largest contiguous block that this object is able to allocate.
StandardAllocator can (theoretically) allocate ~size_type( 0 ) bytes. This poses no practical limit on 64-bit systems.
Definition at line 118 of file StandardAllocator.h.
|
inline |
Returns the size in bytes of a reallocated data block.
currentSize | The current size in bytes of an allocated data block. |
newSize | The new size in bytes of the reallocated data block. |
See IsFastGrowthEnabled() and IsShrinkingEnabled() for information about block size allocation and reallocation policies in StandardAllocator.
Definition at line 180 of file StandardAllocator.h.