|
wavelength 1.0.0
|
#include <stdbool.h>#include <stddef.h>#include <stdio.h>

Go to the source code of this file.
Functions | |
| void * | PoolAlloc (int nSize, int nBlockSize, const char *pszTag, int nUnused) |
| Allocate a block from the small-block pool and bill it to a tag. | |
| void | PoolFree (int nSize, void *pBlock) |
| Return a block to the small-block pool. | |
| void | PoolReport (PrnStream &stream) |
| Write the use of the small-block pool. | |
| int | MemGetHeap () |
| Report the heap that PoolMemAlloc() allocates from, the top of the heap stack. | |
| void | MemHeapInfo (int nHeap, int *pnBlocks, int *pnFreeBytes, int *pnBiggest) |
| Report the free blocks of a heap. | |
| int | MemRegisterHeap (const char *pszName, int *pStart, int nSizeWords, int bHandles) |
| Add a heap to the table. | |
| void | MemSetHeapSize (int nHeap, int nSizeWords) |
| Change the size of a heap. | |
| void | MemPushHeap (int nHeap) |
| Make a heap the one PoolMemAlloc() allocates from, until MemPopHeap(). | |
| void | MemPopHeap () |
| Undo the latest MemPushHeap(). | |
| void | MemInit () |
| Take the memory from the end of the C library's heap to 0x1f70000 as the heap main, and start the memory tracker when it is available. | |
| void * | MemRealloc (void *pBlock, int nBytes) |
| Shrink a block in place. | |
| int | MemNumHeaps () |
| Report the number of heaps. | |
| void | MemPrintHeap (int nHeap, PrnStream &stream) |
| Write each block of a heap. | |
| void * | MemOrPoolAlloc (int nSize, const char *pszTag) |
| Allocate a block of up to 128 bytes from the pool of fixed-size blocks, and a larger block from the pool heaps. | |
| void | MemOrPoolFree (int nSize, void *pBlock) |
| Return a block MemOrPoolAlloc() handed out. | |
| int | MemFindHeap (const char *pszName) |
| Look up a heap by its configured name. | |
| void | MemCompact (int nHeap, int nByteBudget, bool bStrictBudget) |
| Move live blocks of one heap together to merge its free space. | |
| void * | PoolMemAlloc (int nSize, const char *pszTag, int nAlign) |
| Allocate a block from the pool heaps and bill it to a tag. | |
| void | PoolMemFree (void *pBlock) |
| Return a block PoolMemAlloc() handed out to the pool heap that owns it. | |
| void | MemConfigureHeaps () |
| Set the heaps up from the system configuration. | |
| void | MemTerminate () |
| Shut the heaps down. | |
| void | MemPoll () |
| Record the state of every tracked heap, once per frame. | |
Variables | |
| int | g_nMemTrackingEnabled |
| Non-zero while the memory tracker records allocations. | |
| int | g_nTrackStl |
| Non-zero when the memory tracker bills STL allocations to their container, from track_stl. | |
| void * PoolAlloc | ( | int | nSize, |
| int | nBlockSize, | ||
| const char * | pszTag, | ||
| int | nUnused ) |
Allocate a block from the small-block pool and bill it to a tag.
The pool is created on first use.
| nSize | The block size in bytes, which selects the node size of the pool. |
| nBlockSize | Not used. |
| pszTag | The tag to bill the allocation to. |
| nUnused | Not used. |
| void PoolFree | ( | int | nSize, |
| void * | pBlock ) |
Return a block to the small-block pool.
| nSize | The block size given to PoolAlloc(). |
| pBlock | The block. |
| void PoolReport | ( | PrnStream & | stream | ) |
Write the use of the small-block pool.
The name is inferred.
| stream | The stream to write to. |
| int MemGetHeap | ( | ) |
Report the heap that PoolMemAlloc() allocates from, the top of the heap stack.
The name is inferred.
| void MemHeapInfo | ( | int | nHeap, |
| int * | pnBlocks, | ||
| int * | pnFreeBytes, | ||
| int * | pnBiggest ) |
Report the free blocks of a heap.
The name is inferred.
| nHeap | The index of the heap. |
| pnBlocks | Receives the number of free blocks. |
| pnFreeBytes | Receives the free bytes. |
| pnBiggest | Receives the bytes of the biggest free block. |
| int MemRegisterHeap | ( | const char * | pszName, |
| int * | pStart, | ||
| int | nSizeWords, | ||
| int | bHandles ) |
Add a heap to the table.
The name is inferred.
| pszName | The name of the heap. |
| pStart | The region of the heap. |
| nSizeWords | The size of the region in words. |
| bHandles | Non-zero for a heap of handle blocks. |
| void MemSetHeapSize | ( | int | nHeap, |
| int | nSizeWords ) |
Change the size of a heap.
The name is inferred.
| nHeap | The index of the heap. |
| nSizeWords | The size in words. |
| void MemPushHeap | ( | int | nHeap | ) |
Make a heap the one PoolMemAlloc() allocates from, until MemPopHeap().
Make a heap the one allocations come from until the matching MemPopHeap().
The depth of the stack is not checked. The name is inferred.
| nHeap | The index of the heap. |
The name is inferred.
| nHeap | The table index MemFindHeap() reported. |
| void MemPopHeap | ( | ) |
Undo the latest MemPushHeap().
Return to the heap in use before the last MemPushHeap().
The name is inferred.
| void MemInit | ( | ) |
Take the memory from the end of the C library's heap to 0x1f70000 as the heap main, and start the memory tracker when it is available.
PoolMemAlloc() calls this before the first allocation. The name is inferred.
| void * MemRealloc | ( | void * | pBlock, |
| int | nBytes ) |
Shrink a block in place.
A size of 0 frees the block. A block outside every heap is returned as it is.
| pBlock | The block, or null. |
| nBytes | The size in bytes. |
| int MemNumHeaps | ( | ) |
Report the number of heaps.
Report how many heaps the heap table has.
The name is inferred.
The name is inferred.
| void MemPrintHeap | ( | int | nHeap, |
| PrnStream & | stream ) |
Write each block of a heap.
The name is inferred.
| nHeap | The index of the heap. |
| stream | The stream to write to. |
| void * MemOrPoolAlloc | ( | int | nSize, |
| const char * | pszTag ) |
Allocate a block of up to 128 bytes from the pool of fixed-size blocks, and a larger block from the pool heaps.
The name is inferred.
| nSize | The block size in bytes. |
| pszTag | The tag to bill the allocation to. |
| void MemOrPoolFree | ( | int | nSize, |
| void * | pBlock ) |
Return a block MemOrPoolAlloc() handed out.
A null block is ignored. The name is inferred.
| nSize | The size MemOrPoolAlloc() was given. |
| pBlock | The block. |
| int MemFindHeap | ( | const char * | pszName | ) |
Look up a heap by its configured name.
The heap table has one 0x18-byte entry per heap, and the lookup compares the name of each entry in table order.
| pszName | The heap name, for example "rnd". |
| void MemCompact | ( | int | nHeap, |
| int | nByteBudget, | ||
| bool | bStrictBudget ) |
Move live blocks of one heap together to merge its free space.
A negative heap index is ignored. With bStrictBudget set, compaction stops before the first block that would take the bytes moved past the budget. Otherwise compaction stops only after the bytes moved exceed the budget, and the last block moved may cross it.
| nHeap | The table index MemFindHeap() reported. |
| nByteBudget | The most bytes to move in this call. |
| bStrictBudget | Whether the budget is a hard limit. |
| void * PoolMemAlloc | ( | int | nSize, |
| const char * | pszTag, | ||
| int | nAlign ) |
Allocate a block from the pool heaps and bill it to a tag.
Every class-specific operator new forwards here with its class name as the tag, and the global operator new passes the tag new.
| nSize | The block size in bytes. |
| pszTag | The tag to bill the allocation to. |
| nAlign | The alignment in bytes, a power of two of at least four. Zero selects 16 bytes. |
| void PoolMemFree | ( | void * | pBlock | ) |
Return a block PoolMemAlloc() handed out to the pool heap that owns it.
A null block is ignored.
| pBlock | The block. |
| void MemConfigureHeaps | ( | ) |
Set the heaps up from the system configuration.
The name is inferred.
| void MemTerminate | ( | ) |
Shut the heaps down.
The body does nothing. The name is inferred.
| void MemPoll | ( | ) |
Record the state of every tracked heap, once per frame.
The name is inferred.
|
extern |
Non-zero while the memory tracker records allocations.
|
extern |
Non-zero when the memory tracker bills STL allocations to their container, from track_stl.