summaryrefslogtreecommitdiff
path: root/libs/pbd/pool.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-09-12 00:29:02 +0200
committerRobin Gareus <robin@gareus.org>2015-09-12 02:18:38 +0200
commita5e3371b8030920fd9108976fac218660d59bb40 (patch)
tree49a416a99450bd2d850f1d95f9733bae8f86f011 /libs/pbd/pool.cc
parentec06f2c49f1986493b5b9b6b684d00037c373f4f (diff)
Event Pool usage debugging, see also 6ade16b38
Diffstat (limited to 'libs/pbd/pool.cc')
-rw-r--r--libs/pbd/pool.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/libs/pbd/pool.cc b/libs/pbd/pool.cc
index ccdb85b6c6..1fc0949eba 100644
--- a/libs/pbd/pool.cc
+++ b/libs/pbd/pool.cc
@@ -35,6 +35,9 @@ using namespace PBD;
Pool::Pool (string n, unsigned long item_size, unsigned long nitems)
: free_list (nitems)
, _name (n)
+#ifndef NDEBUG
+ , max_usage (0)
+#endif
{
_name = n;
@@ -57,6 +60,10 @@ Pool::Pool (string n, unsigned long item_size, unsigned long nitems)
Pool::~Pool ()
{
+#ifndef NDEBUG
+ // TODO: after collecting some stats, use DEBUG::PoolStats here
+ cerr << "Pool: '" << _name << "' max: " << max_usage << " / " << total() << endmsg;
+#endif
free (block);
}
@@ -68,6 +75,12 @@ Pool::alloc ()
{
void *ptr;
+#ifndef NDEBUG
+ if (used () > max_usage) {
+ max_usage = used () + 1;
+ }
+#endif
+
if (free_list.read (&ptr, 1) < 1) {
fatal << "CRITICAL: " << _name << " POOL OUT OF MEMORY - RECOMPILE WITH LARGER SIZE!!" << endmsg;
abort(); /*NOTREACHED*/