wavelength 1.0.0
Loading...
Searching...
No Matches
mem.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdbool.h>
4#include <stddef.h>
5#include <stdio.h>
6
7#ifdef __cplusplus
8#include <new>
9
10#include "os/prnstream.h"
11#endif
12
13#ifdef __cplusplus
24void *operator new[](size_t nSize);
25
36void *operator new(size_t nSize);
37
49void *operator new(size_t nSize, std::align_val_t nAlign);
50
58void *operator new[](size_t nSize, std::align_val_t nAlign);
59#endif
60
74void *PoolAlloc(int nSize, int nBlockSize, const char *pszTag, int nUnused);
75
84void PoolFree(int nSize, void *pBlock);
85
95void PoolReport(PrnStream &stream);
96
107
120void MemHeapInfo(int nHeap, int *pnBlocks, int *pnFreeBytes, int *pnBiggest);
121
135int MemRegisterHeap(const char *pszName, int *pStart, int nSizeWords, int bHandles);
136
147void MemSetHeapSize(int nHeap, int nSizeWords);
148
158void MemPushHeap(int nHeap);
159
169
179void MemInit();
180
192void *MemRealloc(void *pBlock, int nBytes);
193
204
215void MemPrintHeap(int nHeap, PrnStream &stream);
216
223extern int g_nMemTrackingEnabled;
224
231extern int g_nTrackStl;
232
245void *MemOrPoolAlloc(int nSize, const char *pszTag);
246
257void MemOrPoolFree(int nSize, void *pBlock);
258
259#ifdef __cplusplus
267void operator delete[](void *pBlock) noexcept;
268
276void operator delete(void *pBlock) noexcept;
277
284void operator delete(void *pBlock, std::align_val_t nAlign) noexcept;
285
292void operator delete[](void *pBlock, std::align_val_t nAlign) noexcept;
293#endif
294
306int MemFindHeap(const char *pszName);
307
317void MemPushHeap(int nHeap);
318
327void MemPopHeap();
328
338int MemNumHeaps();
339
353void MemCompact(int nHeap, int nByteBudget, bool bStrictBudget);
354
368void *PoolMemAlloc(int nSize, const char *pszTag, int nAlign);
369
379void PoolMemFree(void *pBlock);
380
390
400
409void MemPoll();
Text output stream.
Definition prnstream.h:16
int MemGetHeap()
Report the heap that PoolMemAlloc() allocates from, the top of the heap stack.
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 p...
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void MemPushHeap(int nHeap)
Make a heap the one PoolMemAlloc() allocates from, until MemPopHeap().
int MemNumHeaps()
Report the number of heaps.
void PoolReport(PrnStream &stream)
Write the use of the small-block pool.
void MemTerminate()
Shut the heaps down.
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.
void MemPopHeap()
Undo the latest MemPushHeap().
void * MemRealloc(void *pBlock, int nBytes)
Shrink a block in place.
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 MemConfigureHeaps()
Set the heaps up from the system configuration.
void MemPoll()
Record the state of every tracked heap, once per frame.
void MemCompact(int nHeap, int nByteBudget, bool bStrictBudget)
Move live blocks of one heap together to merge its free space.
void MemPrintHeap(int nHeap, PrnStream &stream)
Write each block of a heap.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.
int g_nMemTrackingEnabled
Non-zero while the memory tracker records allocations.
void MemOrPoolFree(int nSize, void *pBlock)
Return a block MemOrPoolAlloc() handed out.
void MemInit()
Take the memory from the end of the C library's heap to 0x1f70000 as the heap main,...
void PoolFree(int nSize, void *pBlock)
Return a block to the small-block pool.
int MemFindHeap(const char *pszName)
Look up a heap by its configured name.
void MemHeapInfo(int nHeap, int *pnBlocks, int *pnFreeBytes, int *pnBiggest)
Report the free blocks of a heap.