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

Allocation tracker for one heap. More...

#include <MemTrack.h>

Public Member Functions

 MemTrack (int heap, int *begin, int *end)
 Start tracking a heap.
void SetHeapRange (int *heapBegin, int *heapEnd)
 Follow a heap that grew or shrank.
void CreateStatTables ()
 Create the statistics tables.
void Alloc (int size, const char *type, int actual, void *ptr)
 Record a heap allocation.
void PoolAlloc (int size, const char *type, void *ptr)
 Record a pool node.
void Free (void *ptr, bool pooled)
 Forget an allocation or a pool node.
int BytesFree () const
 Report the bytes of the heap not allocated.
void ReportAllocsByName (PrnStream &stream)
 Print how many allocations share each name and size.
void Report (PrnStream &stream, int minSize)
 Print the heap's totals and its allocations by name.
void DiffReport (PrnStream &stream)
 Print the change of every total since the previous report, then swap the tables.
bool InitOK () const
 Report whether the mirror array was allocated.

Detailed Description

Allocation tracker for one heap.

A mirror array holds an AllocInfo pointer for every word of the heap where an allocation starts. Two pairs of BlockStatTable alternate between reports. Each report prints the change since the previous one. The object is 0xe4 bytes. The name comes from the source file.

Constructor & Destructor Documentation

◆ MemTrack()

MemTrack::MemTrack ( int heap,
int * begin,
int * end )

Start tracking a heap.

Parameters
heapThe heap's index.
beginThe heap's first word.
endThe word past the heap.
Ghidra address:
0x100177f0

Member Function Documentation

◆ SetHeapRange()

void MemTrack::SetHeapRange ( int * heapBegin,
int * heapEnd )

Follow a heap that grew or shrank.

The start must not move.

Parameters
heapBeginThe heap's first word.
heapEndThe word past the heap.
Ghidra address:
0x10017880

◆ CreateStatTables()

void MemTrack::CreateStatTables ( )

Create the statistics tables.

Ghidra address:
0x10017920

◆ Alloc()

void MemTrack::Alloc ( int size,
const char * type,
int actual,
void * ptr )

Record a heap allocation.

Parameters
sizeThe bytes requested.
typeThe allocation's name.
actualThe bytes allocated.
ptrThe allocation.
Ghidra address:
0x100179c0

◆ PoolAlloc()

void MemTrack::PoolAlloc ( int size,
const char * type,
void * ptr )

Record a pool node.

Parameters
sizeThe node size in bytes.
typeThe node's name.
ptrThe node.
Ghidra address:
0x10017b00

◆ Free()

void MemTrack::Free ( void * ptr,
bool pooled )

Forget an allocation or a pool node.

Parameters
ptrThe allocation or node.
pooledWhether a pool node is freed.
Ghidra address:
0x10017bd0

◆ BytesFree()

int MemTrack::BytesFree ( ) const

Report the bytes of the heap not allocated.

Returns
The free bytes.
Ghidra address:
0x10017d20

◆ ReportAllocsByName()

void MemTrack::ReportAllocsByName ( PrnStream & stream)

Print how many allocations share each name and size.

Parameters
streamThe destination.
Ghidra address:
0x10017d30

◆ Report()

void MemTrack::Report ( PrnStream & stream,
int minSize )

Print the heap's totals and its allocations by name.

Parameters
streamThe destination.
minSizeThe smallest total, in bytes allocated, that prints.
Ghidra address:
0x10017fe0

◆ DiffReport()

void MemTrack::DiffReport ( PrnStream & stream)

Print the change of every total since the previous report, then swap the tables.

Parameters
streamThe destination.
Ghidra address:
0x100182e0

◆ InitOK()

bool MemTrack::InitOK ( ) const
inline

Report whether the mirror array was allocated.

Returns
Whether tracking works.

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