SAMRAI::tbox::FixedArena Class Reference

#include <source/toolbox/memory/FixedArena.h>

Inheritance diagram for SAMRAI::tbox::FixedArena:

Inheritance graph
[legend]
List of all members.

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

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


Constructor & Destructor Documentation

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.

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.


Member Function Documentation

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.

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.

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.

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

Print out internal class data for debugging.


The documentation for this class was generated from the following files:
Generated on Thu Jun 18 11:29:03 2009 for SAMRAI by  doxygen 1.5.1