CArena Class Reference

: A Concrete Class for Dynamic Memory Management More...

#include <CArena.H>

Inheritance diagram for CArena:

Inheritance graph
[legend]
Collaboration diagram for CArena:

Collaboration graph
[legend]

List of all members.

Public Types

enum  { DefaultHunkSize = 1024*1024 }
 The default memory hunk size to grab from the heap. More...

Public Member Functions

 CArena (size_t hunk_size=0)
 Construct a coalescing memory manager.
virtual ~CArena ()
 The destructor.
virtual void * alloc (size_t nbytes)
 Allocate some memory.
virtual void free (void *ap)
 Free up allocated memory.
size_t heap_space_used () const
 The current amount of heap space used by the CArena object.

Static Public Member Functions

static size_t align (size_t sz)
 Given a minimum required arena size of sz bytes, this returns the next largest arena size that will hold an integral number of objects of the largest of the types void*, long, double and function pointer.

Protected Types

typedef std::set< NodeNL

Protected Attributes

std::vector< void * > m_alloc
NL m_freelist
NL m_busylist
size_t m_hunk
size_t m_used

Classes

class  Node


Detailed Description

: A Concrete Class for Dynamic Memory Management

This is a coalescing memory manager. It allocates (possibly) large chunks of heap space and apportions it out as requested. It merges together neighboring chunks on each free().


Member Typedef Documentation

typedef std::set<Node> CArena::NL [protected]


Member Enumeration Documentation

anonymous enum

The default memory hunk size to grab from the heap.

Enumerator:
DefaultHunkSize 


Constructor & Destructor Documentation

CArena::CArena ( size_t  hunk_size = 0  ) 

Construct a coalescing memory manager.

`hunk' is the minimum size of hunks of memory to allocate from the heap. If hunk == 0 we use DefaultHunkSize as specified below.

References Arena::align(), BL_ASSERT, DefaultHunkSize, m_hunk, and m_used.

CArena::~CArena (  )  [virtual]

The destructor.

References m_alloc.


Member Function Documentation

void * CArena::alloc ( size_t  nbytes  )  [virtual]

void CArena::free ( void *  ap  )  [virtual]

Free up allocated memory.

Merge neighboring free memory chunks into largest possible chunk.

Implements Arena.

References BL_ASSERT, m_busylist, m_freelist, and CArena::Node::size().

size_t CArena::heap_space_used (  )  const

The current amount of heap space used by the CArena object.

References m_used.

size_t Arena::align ( size_t  sz  )  [static, inherited]

Given a minimum required arena size of sz bytes, this returns the next largest arena size that will hold an integral number of objects of the largest of the types void*, long, double and function pointer.

Referenced by alloc(), and CArena().


Member Data Documentation

std::vector<void*> CArena::m_alloc [protected]

Referenced by alloc(), and ~CArena().

NL CArena::m_freelist [protected]

Referenced by alloc(), and free().

NL CArena::m_busylist [protected]

Referenced by alloc(), and free().

size_t CArena::m_hunk [protected]

Referenced by alloc(), and CArena().

size_t CArena::m_used [protected]

Referenced by alloc(), CArena(), and heap_space_used().


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

Generated on Fri Nov 21 10:11:01 2008 for AMRParticlePaths by  doxygen 1.5.5