wavelength 1.0.0
Loading...
Searching...
No Matches
memtrack.h File Reference
#include "os/blockpool.h"
#include "os/heaptracker.h"
#include "os/prnstream.h"
#include "script/dataarray.h"
Include dependency graph for memtrack.h:

Go to the source code of this file.

Functions

bool MemTrackInit ()
 Prepare the pool of AllocInfo records, when the development memory is present.
void MemTrackAddHeap (int nHeap, int *pStart, int *pEnd)
 Track a heap, or move the end of a heap already tracked.
void MemTrackConfigure ()
 Register the script command heap_report, add the heap debug for the reports, and create the statistics tables of each tracker.
void MemTrackAlloc (int nRequested, const char *pszTag, int nActual, void *pData)
 Record an allocation from the heap MemPushHeap() selected.
void MemTrackFree (int nHeap, void *pData)
 Remove the record of an allocation of a heap.
void MemTrackRealloc (int nHeap, void *pOld, int nRequested, int nActual, void *pNew)
 Move the record of an allocation of a heap that changed size or address.
void MemTrackPoolAlloc (int nSize, const char *pszTag, void *pData)
 Mark a block of the small-block pool, which lies in heap 0.
void MemTrackPoolFree (void *pData)
 Remove the marks of a block of the small-block pool.
void * MemTrackBumpAlloc (int nBytes)
 Take 16-byte aligned memory from the development memory above 32 MB, which nothing returns.
void MemTrackReport (int nHeap, int nMinSize, PrnStream &stream)
 Write the time, the report of a heap, and its changes since the previous report.
void MemTrackReportByRecord (int nHeap, PrnStream &stream)
 Write the allocations of a heap counted by record.

Variables

constexpr int kMemTrackMaxHeaps = 16
 The heaps the memory tracker can follow.
HeapTracker * g_apMemTrackHeaps [kMemTrackMaxHeaps]
 The tracker of each heap, or null.
BlockPool g_AllocInfoPool
 The pool of the AllocInfo records of every tracker.

Function Documentation

◆ MemTrackInit()

bool MemTrackInit ( )

Prepare the pool of AllocInfo records, when the development memory is present.

The name is inferred.

Returns
Whether memory tracking is available.
Ghidra address:
NTSC-U/C: 0x0029c268
Ghidra address:
PAL: 0x002a5e88

◆ MemTrackAddHeap()

void MemTrackAddHeap ( int nHeap,
int * pStart,
int * pEnd )

Track a heap, or move the end of a heap already tracked.

The name is inferred.

Parameters
nHeapThe index of the heap.
pStartThe first word of the heap.
pEndThe end of the heap.
Ghidra address:
NTSC-U/C: 0x0029c2c8
Ghidra address:
PAL: 0x002a5ee8

◆ MemTrackConfigure()

void MemTrackConfigure ( )

Register the script command heap_report, add the heap debug for the reports, and create the statistics tables of each tracker.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x0029c4e0
Ghidra address:
PAL: 0x002a6108

◆ MemTrackAlloc()

void MemTrackAlloc ( int nRequested,
const char * pszTag,
int nActual,
void * pData )

Record an allocation from the heap MemPushHeap() selected.

The name is inferred.

Parameters
nRequestedThe bytes requested.
pszTagThe allocation tag.
nActualThe bytes handed out.
pDataThe allocation.
Ghidra address:
NTSC-U/C: 0x0029c580
Ghidra address:
PAL: 0x002a61a8

◆ MemTrackFree()

void MemTrackFree ( int nHeap,
void * pData )

Remove the record of an allocation of a heap.

The name is inferred.

Parameters
nHeapThe index of the heap.
pDataThe allocation.
Ghidra address:
NTSC-U/C: 0x0029c5f8
Ghidra address:
PAL: 0x002a6220

◆ MemTrackRealloc()

void MemTrackRealloc ( int nHeap,
void * pOld,
int nRequested,
int nActual,
void * pNew )

Move the record of an allocation of a heap that changed size or address.

The name is inferred.

Parameters
nHeapThe index of the heap.
pOldThe allocation before the change.
nRequestedThe bytes requested, or -1 to retain them.
nActualThe bytes handed out, or -1 to retain them.
pNewThe allocation after the change.
Ghidra address:
NTSC-U/C: 0x0029c630
Ghidra address:
PAL: 0x002a6258

◆ MemTrackPoolAlloc()

void MemTrackPoolAlloc ( int nSize,
const char * pszTag,
void * pData )

Mark a block of the small-block pool, which lies in heap 0.

The name is inferred.

Parameters
nSizeThe size of the block.
pszTagThe tag of the block.
pDataThe block.
Ghidra address:
NTSC-U/C: 0x0029c668
Ghidra address:
PAL: 0x002a6290

◆ MemTrackPoolFree()

void MemTrackPoolFree ( void * pData)

Remove the marks of a block of the small-block pool.

The name is inferred.

Parameters
pDataThe block.
Ghidra address:
NTSC-U/C: 0x0029c6a0
Ghidra address:
PAL: 0x002a62c8

◆ MemTrackBumpAlloc()

void * MemTrackBumpAlloc ( int nBytes)

Take 16-byte aligned memory from the development memory above 32 MB, which nothing returns.

The name is inferred.

Parameters
nBytesThe bytes.
Returns
The memory, or null without the development memory.
Ghidra address:
NTSC-U/C: 0x0029c738
Ghidra address:
PAL: 0x002a6360

◆ MemTrackReport()

void MemTrackReport ( int nHeap,
int nMinSize,
PrnStream & stream )

Write the time, the report of a heap, and its changes since the previous report.

A development image writes nothing. The name is inferred.

Parameters
nHeapThe index of the heap.
nMinSizeThe fewest bytes handed out for which a tag is listed.
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x0029c028
Ghidra address:
PAL: 0x002a5c48

◆ MemTrackReportByRecord()

void MemTrackReportByRecord ( int nHeap,
PrnStream & stream )

Write the allocations of a heap counted by record.

The name is inferred.

Parameters
nHeapThe index of the heap.
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x0029c0d8
Ghidra address:
PAL: 0x002a5cf8

Variable Documentation

◆ kMemTrackMaxHeaps

int kMemTrackMaxHeaps = 16
constexpr

The heaps the memory tracker can follow.

◆ g_apMemTrackHeaps

HeapTracker* g_apMemTrackHeaps[kMemTrackMaxHeaps]
extern

The tracker of each heap, or null.

Ghidra address:
NTSC-U/C: 0x003b23c8
Ghidra address:
PAL: 0x00431288

◆ g_AllocInfoPool

BlockPool g_AllocInfoPool
extern

The pool of the AllocInfo records of every tracker.

Ghidra address:
NTSC-U/C: 0x005155c0