#include <adskDebugFootprint.h>
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. | |
size_t totalSize | ( | ) | const |
Return the total size of objects collected for.
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.
|
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))
[in] | obj | Pointer to the object being collected |
[in] | howBig | Number of bytes the object occupies (including padding) |
|
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.
[in] | where | Pointer to the class object being added |
[in] | howBig | Size of the class object |
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.
[in] | me | Pointer to object to debug, NULL means class static |
[out] | request | Print request object |
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".
[in] | me | Pointer to object to footprint, NULL means class static |
[out] | request | Footprint object to populate |