# Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy > Class Template Reference
[Internals]

`#include <SmallObj.h>`

Inheritance diagram for Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >:
[legend]
Collaboration diagram for Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >:
[legend]

List of all members.

## Public Types

typedef AllocatorSingleton < ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy > | MyAllocator
| Defines type of allocator.
typedef ThreadingModel < MyAllocator, MutexPolicy > | MyThreadingModel
| Defines type for thread-safety locking mechanism.
typedef Loki::SingletonHolder < MyAllocator, Loki::CreateStatic, LifetimePolicy, ThreadingModel > | MyAllocatorSingleton
| Defines singleton made from allocator.

## Public Member Functions

| AllocatorSingleton ()
| The default constructor is not meant to be called directly.
| ~AllocatorSingleton (void)
| The destructor is not meant to be called directly.

## Static Public Member Functions

static AllocatorSingleton & | Instance (void)
| Returns reference to the singleton.
static void | ClearExtraMemory (void)
static bool | IsCorrupted (void)

## Detailed Description

### template<template< class, class > class ThreadingModel = ::Loki::SingleThreaded, std::size_t chunkSize = 4096, std::size_t maxSmallObjectSize = 256, std::size_t objectAlignSize = 4, template< class > class LifetimePolicy = ::Loki::LongevityLifetime::DieAsSmallObjectParent, class MutexPolicy = ::Loki::Mutex>
class Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >

This template class is derived from SmallObjAllocator in order to pass template arguments into it, and still have a default constructor for the singleton. Each instance is a unique combination of all the template parameters, and hence is singleton only with respect to those parameters. The template parameters have default values and the class has typedefs identical to both SmallObject and SmallValueObject so that this class can be used directly instead of going through SmallObject or SmallValueObject. That design feature allows clients to use the new_handler without having the name of the new_handler function show up in classes derived from SmallObject or SmallValueObject. Thus, the only functions in the allocator which show up in SmallObject or SmallValueObject inheritance hierarchies are the new and delete operators.

## Member Function Documentation

template<template< class, class > class T, std::size_t C, std::size_t M, std::size_t O, template< class > class L, class X >

void Loki::AllocatorSingleton< T, C, M, O, L, X >::ClearExtraMemory | ( | void |  | ) | `[inline, static]`

Clears any excess memory used by the allocator. Complexity is O(F + C) where F is the count of FixedAllocator's in the pool, and C is the number of Chunks in all FixedAllocator's. This never throws.

Note:
  This function can be used as a new_handler when Loki and other memory allocators can no longer allocate. Although the C++ Standard allows new_handler functions to terminate the program when they can not release any memory, this will not do so.

References Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >::Instance(), and Loki::SmallObjAllocator::TrimExcessMemory().

Here is the call graph for this function:

template<template< class, class > class T, std::size_t C, std::size_t M, std::size_t O, template< class > class L, class X >

bool Loki::AllocatorSingleton< T, C, M, O, L, X >::IsCorrupted | ( | void |  | ) | `[inline, static]`

Returns true if anything in implementation is corrupt. Complexity is O(F + C + B) where F is the count of FixedAllocator's in the pool, C is the number of Chunks in all FixedAllocator's, and B is the number of blocks in all Chunks. If it determines any data is corrupted, this will return true in release version, but assert in debug version at the line where it detects the corrupted data. If it does not detect any corrupted data, it returns false.

References Loki::AllocatorSingleton< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >::Instance(), and Loki::SmallObjAllocator::IsCorrupt().

Here is the call graph for this function:

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

- SmallObj.h