Event Pool usage debugging, see also 6ade16b38
This commit is contained in:
parent
ec06f2c49f
commit
a5e3371b80
@ -51,6 +51,9 @@ class LIBPBD_API Pool
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void *block; ///< data storage area
|
void *block; ///< data storage area
|
||||||
|
#ifndef NDEBUG
|
||||||
|
unsigned long max_usage;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class LIBPBD_API SingleAllocMultiReleasePool : public Pool
|
class LIBPBD_API SingleAllocMultiReleasePool : public Pool
|
||||||
|
@ -35,6 +35,9 @@ using namespace PBD;
|
|||||||
Pool::Pool (string n, unsigned long item_size, unsigned long nitems)
|
Pool::Pool (string n, unsigned long item_size, unsigned long nitems)
|
||||||
: free_list (nitems)
|
: free_list (nitems)
|
||||||
, _name (n)
|
, _name (n)
|
||||||
|
#ifndef NDEBUG
|
||||||
|
, max_usage (0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_name = n;
|
_name = n;
|
||||||
|
|
||||||
@ -57,6 +60,10 @@ Pool::Pool (string n, unsigned long item_size, unsigned long nitems)
|
|||||||
|
|
||||||
Pool::~Pool ()
|
Pool::~Pool ()
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
// TODO: after collecting some stats, use DEBUG::PoolStats here
|
||||||
|
cerr << "Pool: '" << _name << "' max: " << max_usage << " / " << total() << endmsg;
|
||||||
|
#endif
|
||||||
free (block);
|
free (block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +75,12 @@ Pool::alloc ()
|
|||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (used () > max_usage) {
|
||||||
|
max_usage = used () + 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (free_list.read (&ptr, 1) < 1) {
|
if (free_list.read (&ptr, 1) < 1) {
|
||||||
fatal << "CRITICAL: " << _name << " POOL OUT OF MEMORY - RECOMPILE WITH LARGER SIZE!!" << endmsg;
|
fatal << "CRITICAL: " << _name << " POOL OUT OF MEMORY - RECOMPILE WITH LARGER SIZE!!" << endmsg;
|
||||||
abort(); /*NOTREACHED*/
|
abort(); /*NOTREACHED*/
|
||||||
|
Loading…
Reference in New Issue
Block a user