mempool Class Reference

Memory pool. More...

#include <mempool.h>

Collaboration diagram for mempool:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 mempool (int is, int bs)
 Creates a memory pool.
 ~mempool ()
 Destroys memory pool.
void map (std::ostream &co)
 Prints a map of memory occupancy.
char * allocate ()
 Allocates a single memory entry.
int free (char *addr)
 Frees a single memory entry.
void stat ()
 Prints statistics about this mempool.
int used ()
 Returns effectively used memory (bytes).
int wasted ()
 Returns amount of wasted memory (bytes).


Detailed Description

Memory pool.

A memory pool is composed of:

Definition at line 59 of file mempool.h.


Constructor & Destructor Documentation

mempool::mempool ( int  is,
int  bs 
)

Creates a memory pool.

The pool contains:

  • entries of size is
  • tables for bs entries

Definition at line 51 of file mempool.cpp.

References NULL.

mempool::~mempool (  ) 

Destroys memory pool.

Definition at line 162 of file mempool.cpp.

References NULL.


Member Function Documentation

char * mempool::allocate (  ) 

Allocates a single memory entry.

Definition at line 91 of file mempool.cpp.

References NULL.

Referenced by ngramcache::add(), storage::allocate(), storage::reallocate(), and htable::search().

Here is the caller graph for this function:

int mempool::free ( char *  addr  ) 

Frees a single memory entry.

Definition at line 136 of file mempool.cpp.

Referenced by storage::free(), and storage::reallocate().

Here is the caller graph for this function:

void mempool::map ( std::ostream &  co  ) 

Prints a map of memory occupancy.

void mempool::stat (  ) 

Prints statistics about this mempool.

Definition at line 208 of file mempool.cpp.

References TRACE_ERR.

int mempool::used (  )  [inline]

Returns effectively used memory (bytes).

includes 8 bytes required by each call of new

Definition at line 90 of file mempool.h.

Referenced by storage::stat(), htable::used(), and wasted().

Here is the caller graph for this function:

int mempool::wasted (  )  [inline]

Returns amount of wasted memory (bytes).

Definition at line 93 of file mempool.h.

References used().

Referenced by storage::stat().

Here is the call graph for this function:

Here is the caller graph for this function:


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

Generated on Fri Apr 15 13:04:15 2011 for Moses by  doxygen 1.5.9