size_t total;
size_t inuse;
size_t maxinuse;
+ size_t malloced;
+ size_t maxmalloced;
size_t hi_water;
size_t lo_water;
isc_boolean_t hi_called;
dl = malloc(sizeof(debuglink_t));
INSIST(dl != NULL);
+ mctx->malloced += sizeof(debuglink_t);
+ if (mctx->malloced > mctx->maxmalloced)
+ mctx->maxmalloced = mctx->malloced;
ISC_LINK_INIT(dl, link);
for (i = 1; i < DEBUGLIST_COUNT; i++) {
ISC_LIST_UNLINK(mctx->debuglist[size],
dl, link);
free(dl);
+ mctx->malloced -= sizeof(*dl);
}
return;
}
ctx->memalloc_failures++;
return (ISC_FALSE);
}
+ ctx->malloced += table_size * sizeof(unsigned char *);
+ if (ctx->malloced > ctx->maxmalloced)
+ ctx->maxmalloced = ctx->malloced;
if (ctx->basic_table_size != 0) {
memmove(table, ctx->basic_table,
ctx->basic_table_size *
sizeof(unsigned char *));
(ctx->memfree)(ctx->arg, ctx->basic_table);
+ ctx->malloced -= ctx->basic_table_size *
+ sizeof(unsigned char *);
}
ctx->basic_table = table;
ctx->basic_table_size = table_size;
ctx->total += increment;
ctx->basic_table[ctx->basic_table_count] = new;
ctx->basic_table_count++;
+ ctx->malloced += NUM_BASIC_BLOCKS * ctx->mem_target;
+ if (ctx->malloced > ctx->maxmalloced)
+ ctx->maxmalloced = ctx->malloced;
curr = new;
next = curr + ctx->mem_target;
ctx->inuse += size;
ctx->stats[ctx->max_size].gets++;
ctx->stats[ctx->max_size].totalgets++;
+ ctx->malloced += size;
+ if (ctx->malloced > ctx->maxmalloced)
+ ctx->maxmalloced = ctx->malloced;
/*
* If we don't set new_size to size, then the
* ISC_MEM_FILL code might write over bytes we
ctx->stats[ctx->max_size].gets--;
INSIST(size <= ctx->inuse);
ctx->inuse -= size;
+ ctx->malloced -= size;
return;
}
ret[size-1] = 0xbe;
# endif
#endif
+ if (ret != NULL) {
+ ctx->malloced += size;
+ if (ctx->malloced > ctx->maxmalloced)
+ ctx->maxmalloced = ctx->malloced;
+ }
return (ret);
}
#endif
#if ISC_MEM_FILL
memset(mem, 0xde, size); /* Mnemonic for "dead". */
-#else
- UNUSED(size);
#endif
(ctx->memfree)(ctx->arg, mem);
+ ctx->malloced -= size;
}
/*!
ctx->total = 0;
ctx->inuse = 0;
ctx->maxinuse = 0;
+ ctx->malloced = sizeof(*ctx);
+ ctx->maxmalloced = sizeof(*ctx);
ctx->hi_water = 0;
ctx->lo_water = 0;
ctx->hi_called = ISC_FALSE;
goto error;
}
memset(ctx->stats, 0, (ctx->max_size + 1) * sizeof(struct stats));
+ ctx->malloced += (ctx->max_size+1) * sizeof(struct stats);
+ ctx->maxmalloced += (ctx->max_size+1) * sizeof(struct stats);
if ((flags & ISC_MEMFLAG_INTERNAL) != 0) {
if (target_size == 0U)
}
memset(ctx->freelists, 0,
ctx->max_size * sizeof(element *));
+ ctx->malloced += ctx->max_size * sizeof(element *);
+ ctx->maxmalloced += ctx->max_size * sizeof(element *);
}
#if ISC_MEM_TRACKLINES
}
for (i = 0; i <= ctx->max_size; i++)
ISC_LIST_INIT(ctx->debuglist[i]);
+ ctx->malloced += (ctx->max_size+1) * sizeof(debuglist_t);
+ ctx->maxmalloced += (ctx->max_size+1) * sizeof(debuglist_t);
}
#endif
ISC_LIST_UNLINK(ctx->debuglist[i],
dl, link);
free(dl);
+ ctx->malloced -= sizeof(*dl);
}
}
(ctx->memfree)(ctx->arg, ctx->debuglist);
+ ctx->malloced -= (ctx->max_size+1) * sizeof(debuglist_t);
}
#endif
INSIST(ctx->references == 0);
}
(ctx->memfree)(ctx->arg, ctx->stats);
+ ctx->malloced -= (ctx->max_size+1) * sizeof(struct stats);
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
- for (i = 0; i < ctx->basic_table_count; i++)
+ for (i = 0; i < ctx->basic_table_count; i++) {
(ctx->memfree)(ctx->arg, ctx->basic_table[i]);
+ ctx->malloced -= NUM_BASIC_BLOCKS * ctx->mem_target;
+ }
(ctx->memfree)(ctx->arg, ctx->freelists);
- if (ctx->basic_table != NULL)
+ ctx->malloced -= ctx->max_size * sizeof(element *);
+ if (ctx->basic_table != NULL) {
(ctx->memfree)(ctx->arg, ctx->basic_table);
+ ctx->malloced -= ctx->basic_table_size *
+ sizeof(unsigned char *);
+ }
}
ondest = ctx->ondestroy;
if ((ctx->flags & ISC_MEMFLAG_NOLOCK) == 0)
DESTROYLOCK(&ctx->lock);
+ ctx->malloced -= sizeof(*ctx);
+ if (ctx->checkfree)
+ INSIST(ctx->malloced == 0);
(ctx->memfree)(ctx->arg, ctx);
isc_ondestroy_notify(&ondest, ctx);
typedef struct summarystat {
isc_uint64_t total;
isc_uint64_t inuse;
+ isc_uint64_t malloced;
isc_uint64_t blocksize;
isc_uint64_t contextsize;
} summarystat_t;
(isc_uint64_t)ctx->maxinuse));
TRY0(xmlTextWriterEndElement(writer)); /* maxinuse */
+ summary->malloced += ctx->malloced;
+ TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "malloced"));
+ TRY0(xmlTextWriterWriteFormatString(writer,
+ "%" ISC_PRINT_QUADFORMAT "u",
+ (isc_uint64_t)ctx->malloced));
+ TRY0(xmlTextWriterEndElement(writer)); /* malloced */
+
+ TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "maxmalloced"));
+ TRY0(xmlTextWriterWriteFormatString(writer,
+ "%" ISC_PRINT_QUADFORMAT "u",
+ (isc_uint64_t)ctx->maxmalloced));
+ TRY0(xmlTextWriterEndElement(writer)); /* maxmalloced */
+
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "blocksize"));
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
summary->blocksize += ctx->basic_table_count *
summary.inuse));
TRY0(xmlTextWriterEndElement(writer)); /* InUse */
+ TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "Malloced"));
+ TRY0(xmlTextWriterWriteFormatString(writer,
+ "%" ISC_PRINT_QUADFORMAT "u",
+ summary.malloced));
+ TRY0(xmlTextWriterEndElement(writer)); /* InUse */
+
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "BlockSize"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
ctx->basic_table_count * sizeof(char *);
summary->total += ctx->total;
summary->inuse += ctx->inuse;
+ summary->malloced += ctx->malloced;
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0)
summary->blocksize += ctx->basic_table_count *
NUM_BASIC_BLOCKS * ctx->mem_target;
CHECKMEM(obj);
json_object_object_add(ctxobj, "maxinuse", obj);
+ obj = json_object_new_int64(ctx->malloced);
+ CHECKMEM(obj);
+ json_object_object_add(ctxobj, "malloced", obj);
+
+ obj = json_object_new_int64(ctx->maxmalloced);
+ CHECKMEM(obj);
+ json_object_object_add(ctxobj, "maxmalloced", obj);
+
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
isc_uint64_t blocksize;
blocksize = ctx->basic_table_count * NUM_BASIC_BLOCKS *
CHECKMEM(obj);
json_object_object_add(memobj, "InUse", obj);
+ obj = json_object_new_int64(summary.malloced);
+ CHECKMEM(obj);
+ json_object_object_add(memobj, "Malloced", obj);
+
obj = json_object_new_int64(summary.blocksize);
CHECKMEM(obj);
json_object_object_add(memobj, "BlockSize", obj);