2005/5/9

     
 

class PagedAllocator

artefaktur
Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Namespace Members   Compound Members   Related Pages  

acdk::lang::sys::PagedAllocator Class Reference

#include <PagedAllocator.h>

Inheritance diagram for acdk::lang::sys::PagedAllocator:

acdk::lang::sys::AbstractAllocator acdk::lang::sys::Allocator acdk::lang::sys::SysObject List of all members.

Public Member Functions

 PagedAllocator (int size, int bufferedPages=100)
virtual ~PagedAllocator ()
virtual void * allocate (size_t size, AllocatedType at=RawMem)
 Allocates Memory.

virtual void deallocate (void *ptr, AllocatedType at=RawMem)
 Frees Memory.

virtual void * raw_allocate (size_t size, AllocatedType type)
virtual void raw_deallocate (size_t size, void *ptr, AllocatedType type)
virtual void listObjects (::acdk::lang::ref::NotifyObjectEventListener *listener, int flags)
PagedAllocatorPage_allocatePage (int size=0)
void _deallocatePage (PagedAllocatorPage *page)
void * allocate (int size, short type)
void dumpStatistics (bool withDetails=false, int memberlevel=0, bool onlyumarked=false)
 dump statistics of Alloctor on cout
  • withDetails dumps with details on heap memory objects
  • memberlevel if memory object is Object, dump information about member recursivly * memberlevel


int getElementCount (AllocatedType type) const
 count of elements in the pages

int getAllocatedCount (AllocatedType type) const
 return number of bytes allocated by given type

bool doGc (bool threadStorage=true, bool force=false)
 try to free memory.


Protected Member Functions

void * _allocate (int size, short type)
void * _allocateObject (int size)
void _deallocateObject (void *ptr)
PagedAllocatorPage_allocatePage2 (int size)
void _deallocatePage2 (PagedAllocatorPage *page)

Protected Attributes

int _standardPageSize
PagedAllocatorPage_first
PagedAllocatorPage_last
int _reservedPages
core_vector< PagedAllocatorPage * > _bufferedPages
int _maxBufferedPages
PagedHeap_heap
 if _heap != 0, Allocator should inform on changes (destroyObject)


Friends

class PagedHeap
class PagedAllocatorObjectsIterator

Constructor & Destructor Documentation

acdk::lang::sys::PagedAllocator::PagedAllocator int  size,
int  bufferedPages = 100
 

virtual acdk::lang::sys::PagedAllocator::~PagedAllocator  )  [virtual]
 


Member Function Documentation

void* acdk::lang::sys::PagedAllocator::_allocate int  size,
short  type
[protected]
 

void* acdk::lang::sys::PagedAllocator::_allocateObject int  size  )  [protected]
 

PagedAllocatorPage* acdk::lang::sys::PagedAllocator::_allocatePage int  size = 0  ) 
 

PagedAllocatorPage* acdk::lang::sys::PagedAllocator::_allocatePage2 int  size  )  [protected]
 

void acdk::lang::sys::PagedAllocator::_deallocateObject void *  ptr  )  [protected]
 

void acdk::lang::sys::PagedAllocator::_deallocatePage PagedAllocatorPage page  ) 
 

void acdk::lang::sys::PagedAllocator::_deallocatePage2 PagedAllocatorPage page  )  [protected]
 

void* acdk::lang::sys::PagedAllocator::allocate int  size,
short  type
 

virtual void* acdk::lang::sys::PagedAllocator::allocate size_t  size,
AllocatedType  at = RawMem
[virtual]
 

Allocates Memory.

It is important, that the Allocator itself will be found in MemChunkHeader directly before this memory location)

Parameters:
size size of Object (not including MemChunkHeader)
Returns:
the raw preinitialized Object not including MemChunkHeader

Reimplemented from acdk::lang::sys::AbstractAllocator.

virtual void acdk::lang::sys::PagedAllocator::deallocate void *  ptr,
AllocatedType  at = RawMem
[virtual]
 

Frees Memory.

Parameters:
ptr points to user object (not including MemChunkHeader)

Reimplemented from acdk::lang::sys::AbstractAllocator.

bool acdk::lang::sys::PagedAllocator::doGc bool  threadStorage = true,
bool  force = false
[virtual]
 

try to free memory.

Returns:
true if any memory was freed
Parameters:
force if true free also internal cached elements for PageAllocator if not true always return false

Reimplemented from acdk::lang::sys::AbstractAllocator.

void acdk::lang::sys::PagedAllocator::dumpStatistics bool  withDetails = false,
int  memberlevel = 0,
bool  onlyumarked = false
 

dump statistics of Alloctor on cout

  • withDetails dumps with details on heap memory objects
  • memberlevel if memory object is Object, dump information about member recursivly * memberlevel

int acdk::lang::sys::PagedAllocator::getAllocatedCount AllocatedType  type  )  const
 

return number of bytes allocated by given type

int acdk::lang::sys::PagedAllocator::getElementCount AllocatedType  type  )  const
 

count of elements in the pages

virtual void acdk::lang::sys::PagedAllocator::listObjects ::acdk::lang::ref::NotifyObjectEventListener listener,
int  flags
[virtual]
 

Parameters:
flags combination of ListObjectsFlags

Implements acdk::lang::sys::AbstractAllocator.

virtual void* acdk::lang::sys::PagedAllocator::raw_allocate size_t  size,
AllocatedType  type
[virtual]
 

Parameters:
size is including MemChunkHeader

Implements acdk::lang::sys::AbstractAllocator.

virtual void acdk::lang::sys::PagedAllocator::raw_deallocate size_t  size,
void *  ptr,
AllocatedType  type
[virtual]
 

Parameters:
size is including MemChunkHeader
ptr is including MemChunkHeader

Implements acdk::lang::sys::AbstractAllocator.


Friends And Related Function Documentation

friend class PagedAllocatorObjectsIterator [friend]
 

friend class PagedHeap [friend]
 


Member Data Documentation

core_vector<PagedAllocatorPage*> acdk::lang::sys::PagedAllocator::_bufferedPages [protected]
 

PagedAllocatorPage* acdk::lang::sys::PagedAllocator::_first [protected]
 

PagedHeap* acdk::lang::sys::PagedAllocator::_heap [protected]
 

if _heap != 0, Allocator should inform on changes (destroyObject)

PagedAllocatorPage* acdk::lang::sys::PagedAllocator::_last [protected]
 

int acdk::lang::sys::PagedAllocator::_maxBufferedPages [protected]
 

int acdk::lang::sys::PagedAllocator::_reservedPages [protected]
 

int acdk::lang::sys::PagedAllocator::_standardPageSize [protected]