diff options
author | vng <viktor.govako@gmail.com> | 2012-09-07 19:17:44 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:43:11 +0300 |
commit | a83a3c97ddaf5cac08d4c999f067b670f4303cdd (patch) | |
tree | f186951858edd0fb7a7e8afe17fc1861b6f12122 /base/object_tracker.hpp | |
parent | dd63cdd69f687b6e5e5557cbaf3a7d5036bdb820 (diff) |
Add simple objects tracker class for leaks finding.
Diffstat (limited to 'base/object_tracker.hpp')
-rw-r--r-- | base/object_tracker.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/base/object_tracker.hpp b/base/object_tracker.hpp new file mode 100644 index 0000000000..c2fbe91ae5 --- /dev/null +++ b/base/object_tracker.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include "base.hpp" +#include "mutex.hpp" + +#include "../std/map.hpp" + + +#define TRACKER_MULTITHREADED + +namespace dbg +{ + class ObjectTracker + { + /// Pointer -> Info (Serial number of creation) + static map<void *, size_t> m_map; + static size_t m_counter; + +#ifdef TRACKER_MULTITHREADED + static threads::Mutex m_mutex; +#endif + + static void Add(void *); + static void Remove(void *); + + public: + ObjectTracker(); + ObjectTracker(ObjectTracker const & rhs); + ~ObjectTracker(); + + static void PrintLeaks(); + }; +} |