IBAMR  IBAMR version 0.19.
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
SAMRAI::tbox::FixedArena Class Reference

#include <tbox/FixedArena.h>

Inheritance diagram for SAMRAI::tbox::FixedArena:
Inheritance graph
[legend]

Public Member Functions

 FixedArena (const size_t bytes)
 
virtual ~FixedArena ()
 
virtual void * alloc (const size_t bytes)
 
virtual void free (void *p)
 
virtual Pointer< ArenaallocateArena (const size_t bytes)
 
virtual void printClassData (std::ostream &os) const
 

Static Public Member Functions

static size_t align (const size_t bytes)
 

Private Types

enum  { ArenaAllocationAlignment = 16 }
 

Private Member Functions

 FixedArena (const FixedArena &)
 
void operator= (const FixedArena &)
 

Private Attributes

Pointer< Arenad_arena
 
void * d_pool
 
size_t d_size
 
size_t d_used
 

Detailed Description

Class FixedArena implements a very simple fixed-size memory management scheme. One large chunk of a known size is allocated and then further allocation requests take memory from that pool. Memory is never returned to the local pool via free, although memory is freed when the object exits.

Note that the size of the memory arena must be calculated including alignment space; all memory requests are aligned on boundaries as defined by Arena::align().

See also
tbox::Arena

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
privateinherited
Enumerator
ArenaAllocationAlignment 

Constructor & Destructor Documentation

◆ FixedArena() [1/2]

SAMRAI::tbox::FixedArena::FixedArena ( const size_t  bytes)

Allocate a fixed-size memory arena. Multiple allocation requests may be made to this arena via alloc() and the specially defined new operators (see Arena). The size of the fixed arena must include padding space, since all memory will be allocated aligned as defined in Arena.

◆ ~FixedArena()

virtual SAMRAI::tbox::FixedArena::~FixedArena ( )
virtual

Release the memory associated with the fixed arena. Objects that allocate from a fixed arena must make sure that the arena lives longer than the need for the buffer space. To ensure that the fixed arena lives long enough, objects might wish to cache a smart pointer to the arena object so that the actual arena object is not deleted until all objects using the arena are deleted.

◆ FixedArena() [2/2]

SAMRAI::tbox::FixedArena::FixedArena ( const FixedArena )
private

Member Function Documentation

◆ alloc()

virtual void* SAMRAI::tbox::FixedArena::alloc ( const size_t  bytes)
virtual

Allocate an aligned portion of memory from the fixed arena. Allocations that exceed the arena space cause the program to abort with a memory overrun exception.

Implements SAMRAI::tbox::Arena.

◆ free()

virtual void SAMRAI::tbox::FixedArena::free ( void *  p)
virtual

Return allocated memory to the fixed arena. For FixedArena, the memory is not actually returned to the free memory pool until the object is destroyed. Thus, free() is a null operation.

Implements SAMRAI::tbox::Arena.

◆ allocateArena()

virtual Pointer<Arena> SAMRAI::tbox::FixedArena::allocateArena ( const size_t  bytes)
virtual

Allocate a fixed arena of the specified size. Subclasses should override allocateArena() to return the proper subclass type.

◆ printClassData()

virtual void SAMRAI::tbox::FixedArena::printClassData ( std::ostream &  os) const
virtual

Print out internal class data for debugging.

◆ operator=()

void SAMRAI::tbox::FixedArena::operator= ( const FixedArena )
private

◆ align()

static size_t SAMRAI::tbox::Arena::align ( const size_t  bytes)
staticinherited

Static arena function to compute alignment for memory allocation. Data allocations less than the alignment size are rounded up to the next multiple of the allocation size. All data allocations are aligned on 16 byte boundaries. Thus, a memory allocation of only 9 bytes will actually return a 16 byte chunk of memory.

Member Data Documentation

◆ d_arena

Pointer<Arena> SAMRAI::tbox::FixedArena::d_arena
private

◆ d_pool

void* SAMRAI::tbox::FixedArena::d_pool
private

◆ d_size

size_t SAMRAI::tbox::FixedArena::d_size
private

◆ d_used

size_t SAMRAI::tbox::FixedArena::d_used
private

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