libMesh
Classes | Public Member Functions | Static Public Member Functions | List of all members
libMesh::PoolAllocator< T > Class Template Reference

An allocator which can be used in standard containers. More...

#include <pool_allocator.h>

Inheritance diagram for libMesh::PoolAllocator< T >:
[legend]

Classes

struct  rebind
 Methods required for copy construction of containers using this allocator. More...
 

Public Member Functions

 PoolAllocator ()
 
 PoolAllocator (const PoolAllocator &o)
 
 PoolAllocator ()
 
 PoolAllocator (const PoolAllocator &o)
 

Static Public Member Functions

static bool release_memory ()
 Frees every memory block that doesn't have any allocated chunks. More...
 
static bool purge_memory ()
 Frees every memory block. More...
 
static bool release_memory ()
 Frees every memory block that doesn't have any allocated chunks. More...
 
static bool purge_memory ()
 Frees every memory block. More...
 

Detailed Description

template<typename T>
class libMesh::PoolAllocator< T >

An allocator which can be used in standard containers.

Uses pool-based memory allocation to efficiently allocate many small objects.

Note
Object destruction returns memory to the pool rather than deallocate it. It must be explicitly deallocated prior to program termination.
Author
Benjamin S. Kirk
Date
2011 Boost-derived allocator that can be used with std::containers.

A wrapper for std::allocator<> when Boost is not available.

Author
Benjamin S. Kirk
Date
2011 PoolAllocator is std::allocator when Boost is not available.

Definition at line 53 of file pool_allocator.h.

Constructor & Destructor Documentation

template<typename T >
libMesh::PoolAllocator< T >::PoolAllocator ( )

Definition at line 66 of file pool_allocator.h.

66  :
67  boost::pool_allocator<T>()
68  {}
template<typename T >
libMesh::PoolAllocator< T >::PoolAllocator ( const PoolAllocator< T > &  o)
explicit

Definition at line 70 of file pool_allocator.h.

70  :
71  boost::pool_allocator<T>(o)
72  {}
template<typename T >
libMesh::PoolAllocator< T >::PoolAllocator ( )

Definition at line 178 of file pool_allocator.h.

178  :
179  std::allocator<T>()
180  {}
template<typename T >
libMesh::PoolAllocator< T >::PoolAllocator ( const PoolAllocator< T > &  o)
explicit

Definition at line 182 of file pool_allocator.h.

182  :
183  std::allocator<T>(o)
184  {}

Member Function Documentation

template<typename T >
static bool libMesh::PoolAllocator< T >::purge_memory ( )
static

Frees every memory block.

This function invalidates any pointers previously returned by allocation functions.

Returns
true if at least one memory block was freed.

Definition at line 89 of file pool_allocator.h.

90  {
91  return boost::singleton_pool<boost::pool_allocator_tag, sizeof(T)>::purge_memory();
92  }
template<typename T >
static bool libMesh::PoolAllocator< T >::purge_memory ( )
static

Frees every memory block.

This function invalidates any pointers previously returned by allocation functions.

Returns
true if at least one memory block was freed.

Definition at line 198 of file pool_allocator.h.

198 { /* no-op for std::allocator<> - already freed. */ return false; }
template<typename T >
static bool libMesh::PoolAllocator< T >::release_memory ( )
static

Frees every memory block that doesn't have any allocated chunks.

Returns
true if at least one memory block was freed.

Definition at line 78 of file pool_allocator.h.

79  {
80  return boost::singleton_pool<boost::pool_allocator_tag, sizeof(T)>::release_memory();
81  }
template<typename T >
static bool libMesh::PoolAllocator< T >::release_memory ( )
static

Frees every memory block that doesn't have any allocated chunks.

Returns
true if at least one memory block was freed.

Definition at line 190 of file pool_allocator.h.

190 { /* no-op for std::allocator<> - already freed. */ return false; }

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