[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59593] trunk/blender/intern/guardedalloc/ intern/mallocn.c: include slop-space in debug statistics (gcc/clang only)
Campbell Barton
ideasman42 at gmail.com
Wed Aug 28 12:17:26 CEST 2013
Revision: 59593
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59593
Author: campbellbarton
Date: 2013-08-28 10:17:26 +0000 (Wed, 28 Aug 2013)
Log Message:
-----------
include slop-space in debug statistics (gcc/clang only)
Modified Paths:
--------------
trunk/blender/intern/guardedalloc/intern/mallocn.c
Modified: trunk/blender/intern/guardedalloc/intern/mallocn.c
===================================================================
--- trunk/blender/intern/guardedalloc/intern/mallocn.c 2013-08-28 10:11:49 UTC (rev 59592)
+++ trunk/blender/intern/guardedalloc/intern/mallocn.c 2013-08-28 10:17:26 UTC (rev 59593)
@@ -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 @@
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 @@
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 @@
(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",
More information about the Bf-blender-cvs
mailing list