HDK
|
#include <UT_FMalloc.h>
Public Member Functions | |
UT_FMalloc (const char *filename) | |
~UT_FMalloc () | |
ut_FMemoryPage * | fmalloc (size_t size) |
void | ffree (ut_FMemoryPage *mem) |
void * | lock (ut_FMemoryPage *mem, bool readwrite=true) |
void | modify (ut_FMemoryPage *mem, bool readwrite=true) |
void | unlock (ut_FMemoryPage *mem) |
void | compactTrash () |
int | getEntropy () const |
void | dumpStats () |
FILE * | getFile () |
size_t | getSize (ut_FMemoryPage *mem) |
int64 | getSeek (ut_FMemoryPage *mem) |
void * | getLockedMemory (ut_FMemoryPage *mem) |
Definition at line 32 of file UT_FMalloc.h.
UT_FMalloc::UT_FMalloc | ( | const char * | filename | ) |
UT_FMalloc::~UT_FMalloc | ( | ) |
void UT_FMalloc::compactTrash | ( | ) |
This will garbage collect the disk file. All used pages will be compacted to a better memory layout.
void UT_FMalloc::dumpStats | ( | ) |
Debug builds only to dump statistics on memory usage. Please see UT_Memory for additional information.
void UT_FMalloc::ffree | ( | ut_FMemoryPage * | mem | ) |
Free a block of memory. This allows the block to be re-used. If a locked page is freed, it's contents will not be written to disk regardless of it's read/write status.
ut_FMemoryPage* UT_FMalloc::fmalloc | ( | size_t | size | ) |
Allocate memory from the disk. This creates a memory block which can be accessed at a later time by locking the page in memory.
|
inline |
Get the state of memory fragmentation. There's no metric defined for this yet.
Definition at line 84 of file UT_FMalloc.h.
|
inline |
Query methods for fmalloc. In theory, you probably don't need these, but it might be handy.
The file may not be allocated until a page is actually written to disk, so querying the file pointer may return a null pointer.
Definition at line 70 of file UT_FMalloc.h.
void* UT_FMalloc::getLockedMemory | ( | ut_FMemoryPage * | mem | ) |
This method will return a null ptr if there is no memory locked to the current page. This can be used to find out the state of the page.
int64 UT_FMalloc::getSeek | ( | ut_FMemoryPage * | mem | ) |
Query methods for fmalloc. In theory, you probably don't need these, but it might be handy.
The file may not be allocated until a page is actually written to disk, so querying the file pointer may return a null pointer.
size_t UT_FMalloc::getSize | ( | ut_FMemoryPage * | mem | ) |
Query methods for fmalloc. In theory, you probably don't need these, but it might be handy.
The file may not be allocated until a page is actually written to disk, so querying the file pointer may return a null pointer.
void* UT_FMalloc::lock | ( | ut_FMemoryPage * | mem, |
bool | readwrite = true |
||
) |
Lock the memory in RAM. If the page is marked as read-write, when it's unlocked, it will be re-flushed to disk (regardless of whether the block was actually modified). If it's not flagged as read-write, the in-core memory can be modified without changing the state of the disk contents.
void UT_FMalloc::modify | ( | ut_FMemoryPage * | mem, |
bool | readwrite = true |
||
) |
If the page was locked as read-only, you can change the status to write by calling modify. Alternatively, you can abort the write to disk by passing readwrite=false.
void UT_FMalloc::unlock | ( | ut_FMemoryPage * | mem | ) |
Unlocking the page will release the memory associated with the page. If the memory has been modified, the page will be written to disk (unless the modified flag has been turned off).