Browse Source

use level 2 trace messages for reporting memory usage

Ioannis Koutras 12 years ago
parent
commit
64bfeb1b7f
3 changed files with 12 additions and 5 deletions
  1. 1 1
      DefineOptions.cmake
  2. 4 4
      src/realloc.c
  3. 7 0
      src/statistics.c

+ 1 - 1
DefineOptions.cmake

@@ -2,7 +2,7 @@ set(WITH_SYSTEM_CALLS "none" CACHE STRING "Choose what system calls can be used,
 set(RAW_BLOCKS_TYPE "freelist" CACHE STRING "Choose what raw blocks can be used, options are: freelist, bitmap")
 option(HAVE_LOCKS "Build with POSIX locking mechanisms" ON)
 option(WITH_REALLOC "Build with realloc" OFF)
-set(TRACE_LEVEL 1 CACHE INTEGER "Choose the trace level, options are: 0, 1, 2 and 3")
+set(TRACE_LEVEL 2 CACHE INTEGER "Choose the trace level, options are: 0, 1, 2 and 3")
 set(STATS "global" CACHE STRING "Choose if the memory allocator keeps internally statistics per raw block or globally, options are: none, rawblock, global")
 option(WITH_DEBUG "Build with debugging functions" ON)
 option(WITH_EXAMPLES "Build with examples" OFF)

+ 4 - 4
src/realloc.c

@@ -116,12 +116,12 @@ void * realloc(void *ptr, size_t size) {
 #ifdef WITH_ALLOCATOR_STATS
             systemallocator.dmm_stats.total_mem_allocated -=
                 remaining_size;
-            TRACE_2("dmmlib - global allocated memory: %zu bytes\n",
+            TRACE_2("dmmlib - ms all %zu\n",
                     systemallocator.dmm_stats.total_mem_allocated);
 #ifdef REQUEST_SIZE_INFO
             systemallocator.dmm_stats.total_mem_requested -=
                 remaining_size;
-            TRACE_2("dmmlib - global requested memory: %zu bytes\n",
+            TRACE_2("dmmlib - ms req %zu\n",
                     systemallocator.dmm_stats.total_mem_requested);
 #endif /* REQUEST_SIZE_INFO */
             systemallocator.dmm_stats.num_realloc++;
@@ -153,12 +153,12 @@ void * realloc(void *ptr, size_t size) {
 #ifdef WITH_ALLOCATOR_STATS
                 systemallocator.dmm_stats.total_mem_allocated +=
                     size_diff;
-                TRACE_1("dmmlib - global allocated memory: %zu bytes\n",
+                TRACE_2("dmmlib - ms all %zu\n",
                         systemallocator.dmm_stats.total_mem_allocated);
 #ifdef REQUEST_SIZE_INFO
                 systemallocator.dmm_stats.total_mem_requested +=
                     size_diff;
-                TRACE_1("dmmlib - global requested memory: %zu bytes\n",
+                TRACE_2("dmmlib - ms req %zu\n",
                         systemallocator.dmm_stats.total_mem_requested);
 #endif /* REQUEST_SIZE_INFO */
                 systemallocator.dmm_stats.num_realloc++;

+ 7 - 0
src/statistics.c

@@ -24,6 +24,8 @@
 
 #include "statistics.h"
 
+#include "trace.h"
+
 /** Updates a dmmstats_t variable
  *
  * @param dmm_stats Pointer to the dmmstats_t variable.
@@ -62,5 +64,10 @@ void update_stats
         dmm_stats->num_free++;
     }
 
+    TRACE_2("dmmlib - ms all %zu\n", dmm_stats->total_mem_allocated);
+#ifdef REQUEST_SIZE_INFO
+    TRACE_2("dmmlib - ms req %zu\n", dmm_stats->total_mem_requested);
+#endif /* REQUEST_SIZE_INFO */
+
 }