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=MP_BLOCK_SIZE)
 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 61 of file mempool.h.


Constructor & Destructor Documentation

mempool::mempool ( int  is,
int  bs = MP_BLOCK_SIZE 
)

Creates a memory pool.

The pool contains:

  • entries of size is
  • tables for bs entries

Definition at line 46 of file mempool.cpp.

References NULL.

mempool::~mempool (  ) 

Destroys memory pool.

Definition at line 159 of file mempool.cpp.

References NULL.


Member Function Documentation

char * mempool::allocate (  ) 

Allocates a single memory entry.

Definition at line 87 of file mempool.cpp.

References NULL.

Referenced by ngramcache::add(), storage::allocate(), htable< T >::insert(), and storage::reallocate().

Here is the caller graph for this function:

int mempool::free ( char *  addr  ) 

Frees a single memory entry.

Definition at line 132 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 205 of file mempool.cpp.

References VERBOSE.

int mempool::used (  )  [inline]

Returns effectively used memory (bytes).

includes 8 bytes required by each call of new

Definition at line 93 of file mempool.h.

Referenced by ngramcache::stat(), storage::stat(), htable< int * >::used(), and wasted().

Here is the caller graph for this function:

int mempool::wasted (  )  [inline]

Returns amount of wasted memory (bytes).

Definition at line 98 of file mempool.h.

References used().

Referenced by ngramcache::stat(), and 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 Thu Jul 6 00:31:51 2017 for Moses by  doxygen 1.5.9