Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Allocator Class Reference

Allocator. More...

#include <allocator.h>

List of all members.

Public Methods

 Allocator (size_t unitSize=0)
 Constructor. More...

 ~Allocator ()
 Destructor.

void * get (size_t unitSize=0)
 Gets memory unit. More...

void put (void *unit)
 Puts memory unit previously obtained by get() method back. More...


Private Types

enum  e { NUM_UNITS_IN_BLOCK = 50 }
 constants. More...


Private Methods

void allocNewBlock ()
 Allocates new block of units.


Private Attributes

void * _freeUnits
 list of free units.

void * _blocks
 list of allocated blocks.

size_t _unitSize
 size of unit.


Detailed Description

Allocator.

This class serves for allocation of memory units of a fixed size specified during initialization. On average it should be faster than using the new() operator directly, because several units are allocated at once in one larger block. The allocator is used in conjunction with overloaded new() and delete() operators of a class to make frequent allocation of its instances more effective.

Author:
Petr Luner, Marek Przeczek

Definition at line 53 of file allocator.h.


Member Enumeration Documentation

enum Allocator::e [private]
 

constants.

Enumeration values:
NUM_UNITS_IN_BLOCK  number of units in one block.

Definition at line 56 of file allocator.h.


Constructor & Destructor Documentation

Allocator::Allocator size_t    unitSize = 0 [inline]
 

Constructor.

Parameters:
unitSize  size of memory unit

Definition at line 79 of file allocator.h.


Member Function Documentation

void * Allocator::get size_t    unitSize = 0
 

Gets memory unit.

If the 'unitSize' argument is supplied and the size of memory unit hasn't been already initialized, it is initialized to 'unitSize'.

Parameters:
unitSize  size of memory unit
Returns:
pointer to memory unit

Definition at line 40 of file allocator.cpp.

Referenced by TraceFrame::newArray(), Thread::operator new(), ObjectTable::operator new(), MonTrace::operator new(), MonThreadTrace::operator new(), MonThreadMethod::operator new(), Method::operator new(), IProf::sID::operator new(), GC::operator new(), CpuTrace::operator new(), CpuThreadTrace::operator new(), CpuThreadMethod::operator new(), ClassField::operator new(), Class::operator new(), AllocTrace::operator new(), AllocThreadTrace::operator new(), AllocThreadObjectTrace::operator new(), AllocThreadObjectMethod::operator new(), AllocThreadObject::operator new(), AllocThreadMethod::operator new(), AllocObjectTrace::operator new(), AllocObjectMethod::operator new(), AllocObject::operator new(), AllocInstance::operator new(), AllocGlobalRef::operator new(), and AllocArena::operator new().

void Allocator::put void *    unit
 

Puts memory unit previously obtained by get() method back.

Parameters:
unit  pointer to memory unit

Definition at line 52 of file allocator.cpp.

Referenced by TraceFrame::deleteArray(), Thread::operator delete(), ObjectTable::operator delete(), MonTrace::operator delete(), MonThreadTrace::operator delete(), MonThreadMethod::operator delete(), Method::operator delete(), IProf::sID::operator delete(), GC::operator delete(), CpuTrace::operator delete(), CpuThreadTrace::operator delete(), CpuThreadMethod::operator delete(), ClassField::operator delete(), Class::operator delete(), AllocTrace::operator delete(), AllocThreadTrace::operator delete(), AllocThreadObjectTrace::operator delete(), AllocThreadObjectMethod::operator delete(), AllocThreadObject::operator delete(), AllocThreadMethod::operator delete(), AllocObjectTrace::operator delete(), AllocObjectMethod::operator delete(), AllocObject::operator delete(), AllocInstance::operator delete(), AllocGlobalRef::operator delete(), and AllocArena::operator delete().


The documentation for this class was generated from the following files:
Generated on Mon Jan 28 14:53:27 2002 for Java Profiler Dynamic Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001