summaryrefslogtreecommitdiff
path: root/pjlib/include/pj/pool.h
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-07-09 10:05:46 +0000
committerBenny Prijono <bennylp@teluu.com>2006-07-09 10:05:46 +0000
commita567dd53450218eb529055ea47d6453c2ea4c9bc (patch)
tree544f19457e86a9228edd1ae8fa08b4c2688592d0 /pjlib/include/pj/pool.h
parent3d6623d1bb968ddf93a723639d1853136fbc2330 (diff)
Added feature to report peak memory used in caching pool
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@594 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/include/pj/pool.h')
-rw-r--r--pjlib/include/pj/pool.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/pjlib/include/pj/pool.h b/pjlib/include/pj/pool.h
index 3d3215c9..7f7fd2b3 100644
--- a/pjlib/include/pj/pool.h
+++ b/pjlib/include/pj/pool.h
@@ -449,6 +449,32 @@ struct pj_pool_factory
* @param factory The pool factory.
*/
void (*dump_status)( pj_pool_factory *factory, pj_bool_t detail );
+
+ /**
+ * This is optional callback to be called by allocation policy when
+ * it allocates a new memory block. The factory may use this callback
+ * for example to keep track of the total number of memory blocks
+ * currently allocated by applications.
+ *
+ * @param factory The pool factory.
+ * @param size Size requested by application.
+ *
+ * @return MUST return PJ_TRUE, otherwise the block
+ * allocation is cancelled.
+ */
+ pj_bool_t (*on_block_alloc)(pj_pool_factory *factory, pj_size_t size);
+
+ /**
+ * This is optional callback to be called by allocation policy when
+ * it frees memory block. The factory may use this callback
+ * for example to keep track of the total number of memory blocks
+ * currently allocated by applications.
+ *
+ * @param factory The pool factory.
+ * @param size Size freed.
+ */
+ void (*on_block_free)(pj_pool_factory *factory, pj_size_t size);
+
};
/**
@@ -557,6 +583,17 @@ struct pj_caching_pool
pj_size_t used_count;
/**
+ * Total size of memory currently used by application.
+ */
+ pj_size_t used_size;
+
+ /**
+ * The maximum size of memory used by application throughout the life
+ * of the caching pool.
+ */
+ pj_size_t peak_used_size;
+
+ /**
* Lists of pools in the cache, indexed by pool size.
*/
pj_list free_list[PJ_CACHING_POOL_ARRAY_SIZE];