Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-08-28 14:17:26 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-08-28 14:17:26 +0400
commitd1d6a132974db8b5dd19c6ee9a4d0af487e1491a (patch)
tree9ef419ff27d4f0aac49c8afbd59cd06d1858ef09 /intern/guardedalloc
parent562313bfd3479fc64b205388e0fbf1891c1ff7b1 (diff)
include slop-space in debug statistics (gcc/clang only)
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r--intern/guardedalloc/intern/mallocn.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c
index 0af16e58f0a..27b85f41a88 100644
--- a/intern/guardedalloc/intern/mallocn.c
+++ b/intern/guardedalloc/intern/mallocn.c
@@ -48,6 +48,11 @@
# define __func__ __FUNCTION__
#endif
+/* only for utility functions */
+#if defined(__GNUC__)
+#include <malloc.h>
+#endif
+
#include "MEM_guardedalloc.h"
/* should always be defined except for experimental cases */
@@ -620,7 +625,9 @@ void MEM_printmemlist_stats(void)
MemHead *membl;
MemPrintBlock *pb, *printblock;
int totpb, a, b;
-
+#ifdef __GNUC__
+ size_t mem_in_use_slop;
+#endif
mem_lock_thread();
/* put memory blocks into array */
@@ -640,6 +647,11 @@ void MEM_printmemlist_stats(void)
totpb++;
pb++;
+#ifdef __GNUC__
+ mem_in_use_slop += (sizeof(MemHead) + sizeof(MemTail) +
+ malloc_usable_size((void *)membl)) - membl->len;
+#endif
+
if (membl->next)
membl = MEMNEXT(membl->next);
else break;
@@ -668,6 +680,10 @@ void MEM_printmemlist_stats(void)
(double)mem_in_use / (double)(1024 * 1024));
printf("peak memory len: %.3f MB\n",
(double)peak_mem / (double)(1024 * 1024));
+#ifdef __GNUC__
+ printf("slop memory len: %.3f MB\n",
+ (double)mem_in_use_slop / (double)(1024 * 1024));
+#endif
printf(" ITEMS TOTAL-MiB AVERAGE-KiB TYPE\n");
for (a = 0, pb = printblock; a < totpb; a++, pb++) {
printf("%6d (%8.3f %8.3f) %s\n",