Footprint Class Reference

#include <adskDebugFootprint.h>

Class Description

Class implementing the gathering of data footprint information.

It's always useful to know how much space your data occupies and how spread out it is. This class provides a simple method to gather that information for reporting and analysis. It's set up to accumulate data of interest recursively from a set of root objects.

This base implementation just collects total sizes. More complex implementations could gather size bucketing information, avoid collecting duplicates, track memory fragmentation, etc.

By putting it into a hierarchy you can choose how efficient the collection will be by the footprint object type you instantiate.

Public Member Functions

 Footprint ()
 Default constructor - does nothing.
 
virtual ~Footprint ()
 Default destructor - does nothing.
 
size_t totalSize () const
 Return the total size of objects collected for. More...
 
size_t totalFragments () const
 Return the total number of objects collected for. More...
 
virtual void clear ()
 Clear out current footprint information.
 
virtual void addMember (const void *where, size_t howBig)
 Use to add members of an object (e.g. strlen of a char*) More...
 
virtual void addObject (const void *where, size_t howBig)
 Use to add real objects (e.g. "this" in a class) More...
 

Static Public Member Functions

static bool Debug (const Footprint *me, Print &request)
 Answer a Print request for a Footprint object. More...
 
static bool Debug (const Footprint *me, Footprint &request)
 Answer a footprint request for a Footprint object. More...
 

Public Attributes

bool fSkipObject
 Count of objects in distinct locations.
 

Member Function Documentation

size_t totalSize ( ) const

Return the total size of objects collected for.

Returns
Number of bytes reported for objects so far
size_t totalFragments ( ) const

Return the total number of objects collected for.

This count is useful for determining a rough estimate of fragmentation. The more objects there are the greater the possibility of fragmentation.

Returns
Number of objects so far
void addMember ( const void *  obj,
size_t  howBig 
)
virtual

Use to add members of an object (e.g. strlen of a char*)

Add a new object to the footprint statistics.

Don't use this for real class objects, only native types. e.g. for a char* member in a class you'd use addMember(me->myStr, strlen(me->myStr))

Parameters
[in]objPointer to the object being collected
[in]howBigNumber of bytes the object occupies (including padding)
void addObject ( const void *  where,
size_t  howBig 
)
virtual

Use to add real objects (e.g. "this" in a class)

Add a class object to the footprint statistics.

Use this version when adding real class objects. See the ParentFootprint macro in adskFootprint.h for information on collecting footprint information in a class hierarchy using this method.

Parameters
[in]wherePointer to the class object being added
[in]howBigSize of the class object
bool Debug ( const Footprint me,
Print request 
)
static

Answer a Print request for a Footprint object.

Use the request object to dump all information on the "me" Footprint, or all static Footprint information if "me" is NULL.

Parameters
[in]mePointer to object to debug, NULL means class static
[out]requestPrint request object
Returns
True if the request was successfully processed.
bool Debug ( const Footprint me,
Footprint request 
)
static

Answer a footprint request for a Footprint object.

Populate the Footprint request with the information on all data stored within this class if "me" is NULL, otherwise the information stored in the Footprint object pointed at by "me".

Parameters
[in]mePointer to object to footprint, NULL means class static
[out]requestFootprint object to populate
Returns
True if the request was successfully processed. The Footprint object will have all information added to it.

The documentation for this class was generated from the following files:
  • adskDebugFootprint.h
  • adskDebugFootprint.cpp