PCL
pcl::StandardAllocator Class Reference

A block allocator class that uses the standard new and delete operators. More...

#include <StandardAllocator.h>

+ Inheritance diagram for pcl::StandardAllocator:

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
 

Detailed Description

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.

See also
Allocator, AlignedAllocator

Definition at line 81 of file StandardAllocator.h.

Constructor & Destructor Documentation

◆ StandardAllocator() [1/2]

pcl::StandardAllocator::StandardAllocator ( bool  fastGrowth = true,
bool  canShrink = true 
)
inline

Constructs a StandardAllocator object.

Parameters
fastGrowthWhether to enable the fast block size growing policy for this allocator.
canShrinkWhether 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.

◆ StandardAllocator() [2/2]

pcl::StandardAllocator::StandardAllocator ( const StandardAllocator )
default

Copy constructor.

Member Function Documentation

◆ AllocateBlock()

void* pcl::StandardAllocator::AllocateBlock ( size_type  size)
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.

Note
This member function is mandatory for a block allocator to be usable by the Allocator class.
See also
DeallocateBlock()

Definition at line 195 of file StandardAllocator.h.

◆ BlockSize()

size_type pcl::StandardAllocator::BlockSize ( size_type  n) const
inline

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.

Note
This member function is mandatory for a block allocator to be usable by the Allocator class.
See also
ReallocatedBlockSize(), IsFastGrowthEnabled()

Definition at line 135 of file StandardAllocator.h.

◆ DeallocateBlock()

void pcl::StandardAllocator::DeallocateBlock ( void *  p)
inline

Custom deallocation routine. Deallocates a previously allocated contiguous memory block that begins at the specified location p.

Note
This member function is mandatory for a block allocator to be usable by the Allocator class.
See also
AllocateBlock()

Definition at line 210 of file StandardAllocator.h.

◆ DisableFastGrowth()

void pcl::StandardAllocator::DisableFastGrowth ( bool  disable = true)
inline

Disables the fast block size growing policy for StandardAllocator.

See IsFastGrowthEnabled() for more information about block size growing policies.

See also
IsFastGrowthEnabled(), EnableFastGrowth()

Definition at line 263 of file StandardAllocator.h.

◆ DisableShrinking()

void pcl::StandardAllocator::DisableShrinking ( bool  disable = true)
inline

Disables a block shrinking policy for StandardAllocator.

See IsShrinkingEnabled() for more information about block shrinking policies.

See also
IsShrinkingEnabled(), EnableShrinking()

Definition at line 307 of file StandardAllocator.h.

◆ EnableFastGrowth()

void pcl::StandardAllocator::EnableFastGrowth ( bool  enable = true)
inline

Enables the fast block size growing policy for StandardAllocator.

See IsFastGrowthEnabled() for more information about block size growing policies.

See also
IsFastGrowthEnabled(), DisableFastGrowth()

Definition at line 250 of file StandardAllocator.h.

◆ EnableShrinking()

void pcl::StandardAllocator::EnableShrinking ( bool  enable = true)
inline

Enables a block shrinking policy for StandardAllocator.

See IsShrinkingEnabled() for more information about block shrinking policies.

See also
IsShrinkingEnabled(), DisableShrinking()

Definition at line 294 of file StandardAllocator.h.

◆ IsFastGrowthEnabled()

bool pcl::StandardAllocator::IsFastGrowthEnabled ( ) const
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.

See also
EnableFastGrowth(), DisableFastGrowth(), BlockSize()

Definition at line 237 of file StandardAllocator.h.

◆ IsShrinkingEnabled()

bool pcl::StandardAllocator::IsShrinkingEnabled ( ) const
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.

See also
EnableShrinking(), DisableShrinking(), ReallocatedBlockSize()

Definition at line 281 of file StandardAllocator.h.

◆ MaxSize()

size_type pcl::StandardAllocator::MaxSize ( ) const
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.

Note
This member function is mandatory for a block allocator to be usable by the Allocator class.

Definition at line 118 of file StandardAllocator.h.

◆ ReallocatedBlockSize()

size_type pcl::StandardAllocator::ReallocatedBlockSize ( size_type  currentSize,
size_type  newSize 
) const
inline

Returns the size in bytes of a reallocated data block.

Parameters
currentSizeThe current size in bytes of an allocated data block.
newSizeThe new size in bytes of the reallocated data block.

See IsFastGrowthEnabled() and IsShrinkingEnabled() for information about block size allocation and reallocation policies in StandardAllocator.

Note
This member function is mandatory for a block allocator to be usable by the Allocator class.
See also
BlockSize(), IsShrinkingEnabled(), IsFastGrowthEnabled()

Definition at line 180 of file StandardAllocator.h.


The documentation for this class was generated from the following file: