A memory protocol pager for private heap manager.
More...
#include <memory.h>
|
void | assign (memalloc &source) |
| Assign foreign pager to us.
|
|
unsigned | max (void) const |
| Get the maximum number of pages that are permitted.
|
|
| memalloc (const memalloc ©) |
|
| memalloc (size_t page=0) |
| Construct a memory pager.
|
|
unsigned | pages (void) const |
| Get the number of pages that have been allocated from the real heap.
|
|
void | purge (void) |
| Purge all allocated memory and heap pages immediately.
|
|
size_t | size (void) const |
| Get the size of a memory page.
|
|
unsigned | utilization (void) const |
| Determine fragmentation level of acquired heap pages.
|
|
virtual | ~memalloc () |
| Destroy a memory pager.
|
|
|
virtual void * | _alloc (size_t size) |
| Allocate memory from the pager heap.
|
|
page_t * | pager (void) |
| Acquire a new page from the heap.
|
|
A memory protocol pager for private heap manager.
This is used to allocate in an optimized manner, as it assumes no mutex locks are held or used as part of it's own internal processing. It also is designed for optimized performance.
- Author
- David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 61 of file memory.h.
◆ memalloc()
ucommon::memalloc::memalloc |
( |
size_t | page = 0 | ) |
|
Construct a memory pager.
- Parameters
-
page | size to use or 0 for OS allocation size. |
◆ ~memalloc()
virtual ucommon::memalloc::~memalloc |
( |
| ) |
|
|
virtual |
Destroy a memory pager.
Release all pages back to the heap at once.
◆ _alloc()
virtual void * ucommon::memalloc::_alloc |
( |
size_t | size | ) |
|
|
protectedvirtual |
Allocate memory from the pager heap.
The size of the request must be less than the size of the memory page used. This implements the memory protocol allocation method.
- Parameters
-
- Returns
- allocated memory or NULL if not possible.
Reimplemented in ucommon::mempager.
◆ assign()
void ucommon::memalloc::assign |
( |
memalloc & | source | ) |
|
Assign foreign pager to us.
This relocates the heap references to our object, clears the other object.
◆ max()
unsigned ucommon::memalloc::max |
( |
void | | ) |
const |
|
inline |
Get the maximum number of pages that are permitted.
One can use a derived class to set and enforce a maximum limit to the number of pages that will be allocated from the real heap. This is often used to detect and bring down apps that are leaking.
- Returns
- page allocation limit.
Definition at line 117 of file memory.h.
◆ pager()
page_t * ucommon::memalloc::pager |
( |
void | | ) |
|
|
protected |
Acquire a new page from the heap.
This is mostly used internally.
- Returns
- page structure of the newly acquired memory page.
◆ pages()
unsigned ucommon::memalloc::pages |
( |
void | | ) |
const |
|
inline |
Get the number of pages that have been allocated from the real heap.
- Returns
- pages allocated from heap.
Definition at line 106 of file memory.h.
◆ size()
size_t ucommon::memalloc::size |
( |
void | | ) |
const |
|
inline |
Get the size of a memory page.
- Returns
- size of each pager heap allocation.
Definition at line 125 of file memory.h.
◆ utilization()
unsigned ucommon::memalloc::utilization |
( |
void | | ) |
const |
Determine fragmentation level of acquired heap pages.
This is represented as an average % utilization (0-100) and represents the used portion of each allocated heap page verse the page size. Since requests that cannot fit on an already allocated page are moved into a new page, there is some unusable space left over at the end of the page. When utilization approaches 100, this is good. A low utilization may suggest a larger page size should be used.
- Returns
- pager utilization.
◆ bufpager
◆ limit
unsigned ucommon::memalloc::limit |
|
protected |
The documentation for this class was generated from the following file:
- /builddir/build/BUILD/ucommon-7.0.0-build/ucommon-7.0.0/inc/ucommon/memory.h