wavelength 1.0.0
Loading...
Searching...
No Matches
HeapTracker Class Reference

Tracker of the allocations of one heap, with one AllocInfo slot for each word of the heap. More...

#include <heaptracker.h>

Classes

struct  FrameCounts
 Allocations and frees of one frame. More...

Public Member Functions

 HeapTracker (int nHeap, int *pStart, int *pEnd)
 Track a heap, with a cleared slot for each word.
void SetRange (int *pStart, int *pEnd)
 Move the end of the heap after the heap was resized.
void CreateTables ()
 Create the two pairs of statistics tables the reports fill.
void Alloc (int nRequested, const char *pszTag, int nActual, void *pData)
 Record an allocation.
void Realloc (void *pOld, int nRequested, int nActual, void *pNew)
 Move the record of an allocation that changed size or address.
void PoolAlloc (int nSize, const char *pszTag, void *pData)
 Mark the record at an address as a pool block, creating the record when there is none.
void Free (void *pData, bool bPool)
 Remove the record of an allocation, or only its pool block marks.
void Poll ()
 Store the counts of the frame in the history and start new ones.
int FreeBytes ()
 Report the bytes of the heap not handed out.
void ReportByRecord (PrnStream &stream)
 Write the number of allocations with each distinct record, using the heap "debug" for the report's own memory when it exists.
void Report (PrnStream &stream, int nMinSize)
 Write the totals of the heap and the totals of each tag.
void ReportDiff (PrnStream &stream)
 Write the changes of each tag since the previous report, and switch tables.

Static Public Member Functions

static void * operator new (size_t nSize)
 Take a tracker from the memory tracker's own region.
static void operator delete (void *) noexcept
 Ignore the release of a tracker.

Static Public Attributes

static constexpr int kHistorySize = 20
 The frames of allocation counts Poll() retains.

Detailed Description

Tracker of the allocations of one heap, with one AllocInfo slot for each word of the heap.

The class is not polymorphic. The name is inferred. MemTrackAddHeap() creates one for each heap while memory tracking is available.

Constructor & Destructor Documentation

◆ HeapTracker()

HeapTracker::HeapTracker ( int nHeap,
int * pStart,
int * pEnd )

Track a heap, with a cleared slot for each word.

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

Member Function Documentation

◆ operator new()

void * HeapTracker::operator new ( size_t nSize)
static

Take a tracker from the memory tracker's own region.

Parameters
nSizeThe size of the tracker.
Returns
The tracker.

◆ operator delete()

void HeapTracker::operator delete ( void * )
inlinestaticnoexcept

Ignore the release of a tracker.

The memory tracker's region never takes memory back.

◆ SetRange()

void HeapTracker::SetRange ( int * pStart,
int * pEnd )

Move the end of the heap after the heap was resized.

mStart stays as it was.

Parameters
pStartThe first word of the heap.
pEndThe end of the heap.
Ghidra address:
NTSC-U/C: 0x0029b2e8
Ghidra address:
PAL: 0x002a4f08

◆ CreateTables()

void HeapTracker::CreateTables ( )

Create the two pairs of statistics tables the reports fill.

Ghidra address:
NTSC-U/C: 0x0029b300
Ghidra address:
PAL: 0x002a4f20

◆ Alloc()

void HeapTracker::Alloc ( int nRequested,
const char * pszTag,
int nActual,
void * pData )

Record an allocation.

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

◆ Realloc()

void HeapTracker::Realloc ( void * pOld,
int nRequested,
int nActual,
void * pNew )

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

Parameters
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: 0x0029b460
Ghidra address:
PAL: 0x002a5080

◆ PoolAlloc()

void HeapTracker::PoolAlloc ( int nSize,
const char * pszTag,
void * pData )

Mark the record at an address as a pool block, creating the record when there is none.

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

◆ Free()

void HeapTracker::Free ( void * pData,
bool bPool )

Remove the record of an allocation, or only its pool block marks.

Parameters
pDataThe allocation.
bPoolWhether a pool block is freed. Its record then goes only when it has no tag.
Ghidra address:
NTSC-U/C: 0x0029b598
Ghidra address:
PAL: 0x002a51b8

◆ Poll()

void HeapTracker::Poll ( )

Store the counts of the frame in the history and start new ones.

Ghidra address:
NTSC-U/C: 0x0029b640
Ghidra address:
PAL: 0x002a5260

◆ FreeBytes()

int HeapTracker::FreeBytes ( )

Report the bytes of the heap not handed out.

Returns
The free bytes.
Ghidra address:
NTSC-U/C: 0x0029b698
Ghidra address:
PAL: 0x002a52b8

◆ ReportByRecord()

void HeapTracker::ReportByRecord ( PrnStream & stream)

Write the number of allocations with each distinct record, using the heap "debug" for the report's own memory when it exists.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x0029b6b8
Ghidra address:
PAL: 0x002a52d8

◆ Report()

void HeapTracker::Report ( PrnStream & stream,
int nMinSize )

Write the totals of the heap and the totals of each tag.

Parameters
streamThe stream to write to.
nMinSizeThe fewest bytes handed out for which a tag is listed.
Ghidra address:
NTSC-U/C: 0x0029b950
Ghidra address:
PAL: 0x002a5570

◆ ReportDiff()

void HeapTracker::ReportDiff ( PrnStream & stream)

Write the changes of each tag since the previous report, and switch tables.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x0029bd30
Ghidra address:
PAL: 0x002a5950

Member Data Documentation

◆ kHistorySize

int HeapTracker::kHistorySize = 20
staticconstexpr

The frames of allocation counts Poll() retains.


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