Empirical
|
A set of macros to track how many instances of specific classes are made. More...
Go to the source code of this file.
Namespaces | |
emp | |
If we are in emscripten, make sure to include the header. | |
emp::internal | |
Functions | |
static std::map< std::string, int > & | emp::internal::TrackMem_GetMap () |
static std::string | emp::internal::TrackMem_Status () |
static void | emp::internal::TrackMem_Inc (const std::string &class_name) |
static void | emp::internal::TrackMem_Dec (const std::string &class_name) |
static int | emp::internal::TrackMem_Count (const std::string &class_name) |
A set of macros to track how many instances of specific classes are made.
One way of tracking memory leaks is to simply count instances of classes. The macros here simplify this process.
To setup, every constructor for a class must incude EMP_TRACK_CONSTRUCT(CLASS_NAME), and every destructor must have EMP_TRACK_DESTRUCT(CLASS_NAME). Make sure to avoid implicit constructors/destructors or counts will be off.
To collect information, EMP_TRACK_COUNT(CLASS_NAME) will provide the current count for a specific class, and EMP_TRACK_STATUS will translate into a string providing information about all available classes.
Developer notes: