--- libaitsess/contrib/Attic/test_mem.c 2012/02/28 09:36:36 1.1.2.6 +++ libaitsess/contrib/Attic/test_mem.c 2012/02/28 12:44:18 1.1.2.11 @@ -21,6 +21,7 @@ main(int argc, char **argv) mpool_t *mp; void *addr; int i; + u_long curr; for (i = 0; i < 3; i++) { addr = malloc(4000); @@ -33,6 +34,10 @@ main(int argc, char **argv) printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); return 1; } + /* + mpool_getquota(mp, &curr, NULL); + printf("___current=%lu\n", curr); + */ for (i = 0; i < 3; i++) { addr = mpool_malloc(mp, 4000, "mdaaa 4000"); @@ -48,17 +53,42 @@ main(int argc, char **argv) // mpool_free(mp, addr, 0); } - printf("1)\n"); + mpool_getquota(mp, &curr, NULL); + printf("___current=%lu\n", curr); + + printf("0) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", + mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, + mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free); mpool_statistics(mp, show); - mpool_free(mp, addr, 0); + addr = mpool_realloc(mp, addr, 1000, "|||||||||||||"); + if (!addr) + printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); + mpool_getquota(mp, &curr, NULL); + printf("addr=%p_current=%lu\n", addr, curr); - printf("2)\n"); + printf("1) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", + mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, + mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free); mpool_statistics(mp, show); + + if (addr) + mpool_free(mp, addr, 0); + + printf("2) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", + mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, + mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free); + mpool_statistics(mp, show); + mpool_purge(mp, 0); - printf("3)\n"); + mpool_getquota(mp, &curr, NULL); + printf("___current=%lu\n", curr); + + printf("3) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", + mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, + mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free); mpool_statistics(mp, show); addr = mpool_malloc(mp, 4000, "mdaaa 4000"); @@ -70,7 +100,9 @@ main(int argc, char **argv) printf("addr=%p chkaddr=%d addr_size=%d\n", addr, mpool_chkaddr(addr), mpool_getsizebyaddr(addr)); mpool_free(mp, addr, 0); - printf("Done.\n"); + printf("4) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", + mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, + mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free); mpool_statistics(mp, show); mpool_destroy(&mp); return 0;