HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_FMalloc Class Reference

#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)
 
voidlock (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)
 
voidgetLockedMemory (ut_FMemoryPage *mem)
 

Detailed Description

Definition at line 32 of file UT_FMalloc.h.

Constructor & Destructor Documentation

UT_FMalloc::UT_FMalloc ( const char *  filename)
UT_FMalloc::~UT_FMalloc ( )

Member Function Documentation

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.

int UT_FMalloc::getEntropy ( ) const
inline

Get the state of memory fragmentation. There's no metric defined for this yet.

Definition at line 84 of file UT_FMalloc.h.

FILE* UT_FMalloc::getFile ( )
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).


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