Loading...
Searching...
No Matches
TfMallocTag::CallTree Struct Reference

Summary data structure for malloc statistics. More...

#include <mallocTag.h>

Classes

struct  CallSite
 Record of the bytes allocated under each different tag. More...
 
struct  PathNode
 Node in the call tree structure. More...
 

Public Types

enum  PrintSetting { TREE = 0 , CALLSITES , BOTH }
 Specify which parts of the report to print. More...
 

Public Member Functions

TF_API std::string GetPrettyPrintString (PrintSetting setting=BOTH, size_t maxPrintedNodes=100000) const
 Return the malloc report string.
 
TF_API void Report (std::ostream &out, const std::string &rootName) const
 Generates a report to the ostream out.
 
TF_API void Report (std::ostream &out) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Public Attributes

std::vector< CallSitecallSites
 All call sites.
 
PathNode root
 Root node of the call-site hierarchy.
 
std::vector< CallStackInfocapturedCallStacks
 The captured malloc stacks.
 

Detailed Description

Summary data structure for malloc statistics.

The CallTree structure is used to deliver a snapshot of the current malloc usage. It is accessible as publicly modifiable data because it is simply a returned snapshot of the current memory state.

Definition at line 60 of file mallocTag.h.


Class Documentation

◆ TfMallocTag::CallTree::CallSite

struct TfMallocTag::CallTree::CallSite

Record of the bytes allocated under each different tag.

Each construction of a TfAutoMallocTag object with a different argument produces a distinct CallSite record. The total bytes outstanding for all memory allocations made under a given call-site are recorded in nBytes, while the name of the call site is available as name.

Definition at line 97 of file mallocTag.h.

Class Members
string name Tag name.
size_t nBytes Allocated bytes.

◆ TfMallocTag::CallTree::PathNode

struct TfMallocTag::CallTree::PathNode

Node in the call tree structure.

A PathNode captures the hierarchy of active TfAutoMallocTag objects that are pushed and popped during program execution. Each PathNode thus describes a sequence of call-sites (i.e. a path down the call tree). Repeated call sites (in the case of co-recursive function calls) can be skipped, e.g. pushing tags "A", "B", "C", "B", "C" leads to only three path-nodes, representing the paths "A", "AB", and "ABC". Allocations done at the bottom (i.e. when tags "A", "B", "C", "B", "C" are all active) are billed to the longest path node in the sequence, which corresponds to the path "ABC").

Path nodes track both the memory they incur directly (nBytesDirect) but more importantly, the total memory allocated by themselves and any of their children (nBytes). The name of a node (siteName) corresponds to the tag name of the final tag in the path.

Definition at line 80 of file mallocTag.h.

Class Members
vector< PathNode > children Children nodes.
size_t nAllocations The number of allocations for this node.
size_t nBytes Allocated bytes by this or descendant nodes.
size_t nBytesDirect Allocated bytes (only for this node).
string siteName Tag name.

Member Enumeration Documentation

◆ PrintSetting

Specify which parts of the report to print.

Enumerator
TREE 

Print the full call tree.

CALLSITES 

Print just the call sites > 0.1%.

BOTH 

Print both tree and call sites.

Definition at line 105 of file mallocTag.h.

Member Function Documentation

◆ GetPrettyPrintString()

TF_API std::string GetPrettyPrintString ( PrintSetting  setting = BOTH,
size_t  maxPrintedNodes = 100000 
) const

Return the malloc report string.

Get a malloc report of the tree and/or callsites.

The columns in the report are abbreviated. Here are the definitions.

TAGNAME : The name of the tag being tracked. This matches the string argument to TfAutoMallocTag constructor.

BytesIncl : Bytes Inclusive. This includes all bytes allocated by this tag and any bytes of its children.

BytesExcl : Bytes Exclusive. Only bytes allocated exclusively by this tag, not including any bytes of its children.

%Prnt : (%% Parent). me.BytesIncl / parent.BytesIncl * 100

%Exc : BytesExcl / BytesIncl * 100

%Totl : (%% Total). BytesExcl / TotalBytes * 100

◆ Report() [1/2]

TF_API void Report ( std::ostream &  out) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Report() [2/2]

TF_API void Report ( std::ostream &  out,
const std::string &  rootName 
) const

Generates a report to the ostream out.

This report is printed in a way that is intended to be used by xxtracediff. If rootName is non-empty it will replace the name of the tree root in the report.

Member Data Documentation

◆ callSites

std::vector<CallSite> callSites

All call sites.

Definition at line 151 of file mallocTag.h.

◆ capturedCallStacks

std::vector<CallStackInfo> capturedCallStacks

The captured malloc stacks.

Definition at line 157 of file mallocTag.h.

◆ root

PathNode root

Root node of the call-site hierarchy.

Definition at line 154 of file mallocTag.h.


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