ost::MemPager(3)
β¨ ost::MemPager(3) β¨
okay bestie, gather round, because we're reading a library functions manual page today and it's lowkey iconic π
this one's from GNU CommonC++, and it's all about ost::MemPager β the memory pager, aka the girl who keeps all your object-specific "persistant" data in cumulative memory pages so it lives as long as your derived object does. yes, "persistant" is spelled like that in the original, we don't fix, we respect π«Ά
πΈ NAME πΈ
ost::MemPager β the memory pager is used to allocate cumulative memory pages for storing object specific 'persistant' data that is presumed to persist during the life of a given derived object. no cap.
π SYNOPSIS π
#include <misc.h>
Inherited by ost::Keydata [protected], ost::SharedMemPager, and ost::StackPager [protected].
π Public Member Functions π
int getPages (void)β Return the total number of pages that have been allocated for this memory pool.
π¦ Protected Member Functions π¦
virtual void * first (size_t size)β Allocate first workspace from paged memory.virtual void * alloc (size_t size)β Allocate memory from either the currently active page, or allocate a new page for the object.char * first (char *str)β Allocate a string from the memory pager pool and copy the string into it's new memory area.char * alloc (const char *str)β Allocate a string from the memory pager pool and copy the string inti it's new memory area. (yes, "inti" β that's the original's typo, we keep it, it's canon π)MemPager (size_t pagesize=4096)β Create a paged memory pool for cumulative storage.void purge (void)β purge the current memory pool.void clean (void)β Clean for memory cleanup before exiting.virtual ~MemPager ()β Delete the memory pool and all allocated memory.
π§ Friends π§
class Stringclass MemPagerObject
π Detailed Description π
The memory pager is used to allocate cumulative memory pages for storing object specific 'persistant' data that is presumed to persist during the life of a given derived object.
When the object is destroyed, all accumulated data is automatically purged. like, it cleans up after itself, we love a tidy queen β¨
There are a number of odd and specialized utility classes found in Common C++. The most common of these is the 'MemPager' class. This is basically a class to enable page-grouped 'cumulative' memory allocation; all accumulated allocations are dropped during the destructor. This class has found it's way in a lot of other utility classes in Common C++.
Author
David Sugar dyfet@ostel.com
Accumulative object memory allocator.
π Constructor & Destructor Documentation π
β ost::MemPager::MemPager (size_t pagesize = 4096) [protected]
Create a paged memory pool for cumulative storage. This pool allocates memory in fixed 'pagesize' chunks. Ideal performance is achived when the pool size matches the system page size. This pool can only exist in derived objects. (yep, "achived" β original spelling, no touchy π)
Parameters
- pagesize β page size to allocate chunks.
π virtual ost::MemPager::~MemPager () [protected], [virtual]
Delete the memory pool and all allocated memory. everything goes. poof. gone. bye π¨
π₯ Member Function Documentation π₯
πΈ char* ost::MemPager::alloc (const char * str) [protected]
Allocate a string from the memory pager pool and copy the string inti it's new memory area. This checks only the last active page for available space before allocating a new page.
Parameters
- str β string to allocate and copy into paged memory pool.
Returns
copy of string from allocated memory.
π virtual void* ost::MemPager::alloc (size_t size) [protected], [virtual]
Allocate memory from either the currently active page, or allocate a new page for the object.
Parameters
- size β size of memory to allocate.
Returns
pointer to allocated memory.
Reimplemented in ost::SharedMemPager.
π¦ void ost::MemPager::clean (void) [protected]
Clean for memory cleanup before exiting.
π char* ost::MemPager::first (char * str) [protected]
Allocate a string from the memory pager pool and copy the string into it's new memory area. This method allocates memory by first searching for an available page, and then allocating a new page if no space is found.
Parameters
- str β string to allocate and copy into paged memory pool.
Returns
copy of string from allocated memory.
β¨ virtual void* ost::MemPager::first (size_t size) [protected], [virtual]
Allocate first workspace from paged memory. This method scans all currently allocated blocks for available space before adding new pages and hence is both slower and more efficient. it's giving thorough. it's giving extra effort. respect π«Ά
Parameters
- size β size of memory to allocate.
Returns
pointer to allocated memory.
Reimplemented in ost::SharedMemPager.
π int ost::MemPager::getPages (void) [inline]
Return the total number of pages that have been allocated for this memory pool.
Returns
number of pages allocated.
π
void ost::MemPager::purge (void) [protected]
purge the current memory pool.
π Friends And Related Function Documentation π
friend class MemPagerObject[friend]friend class String[friend]
π Author π
Generated automatically by Doxygen for GNU CommonC++ from the source code.
and that's the whole page, bestie β every flag, every param, every return value, untouched, just wrapped in sparkles π
okay so final sign-off: this whole thing is GNU CommonC++, and the page is dated Sun Dec 27 2020 β so yeah, we're reading ost::MemPager(3) and it ate, no crumbs left. periodt πβ¨π¦
π¦ where this page comes from
- ubuntu jammy: libcommoncpp2-doc 1.8.1-10
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms