소스 검색

Statistics and proper return address when memory requests are not properly served in bitmap-organised blocks and need direct mmap() calls

Ioannis Koutras 12 년 전
부모
커밋
f7c02a92a8
1개의 변경된 파일22개의 추가작업 그리고 0개의 파일을 삭제
  1. 22 0
      src/dmmlib.c

+ 22 - 0
src/dmmlib.c

@@ -125,6 +125,28 @@ void * malloc(size_t size) {
             if(ptr == NULL) {
                 ptr = (void *) create_new_raw_block(size +
                         sizeof(raw_block_header_t), BIGBLOCK);
+
+                if(ptr != NULL) {
+                    TRACE_1("dmmlib - malloc - allocated a whole raw block of %zu"
+                            " bytes at %p\n", size + sizeof(raw_block_header_t),
+                            (void *)ptr);
+
+#ifdef WITH_ALLOCATOR_STATS
+                    systemallocator.dmm_stats.total_mem_allocated +=
+                        size + sizeof(raw_block_header_t);
+                    systemallocator.dmm_stats.live_objects++;
+                    systemallocator.dmm_stats.num_malloc++;
+                    TRACE_1("dmmlib - global allocated memory: %zu bytes\n",
+                            systemallocator.dmm_stats.total_mem_allocated);
+#ifdef REQUEST_SIZE_INFO
+                    systemallocator.dmm_stats.total_mem_requested += size;
+                    TRACE_1("dmmlib - global requested memory: %zu bytes\n",
+                            systemallocator.dmm_stats.total_mem_requested);
+#endif /* REQUEST_SIZE_INFO */
+#endif /* WITH_ALLOCATOR_STATS */
+
+                    ptr = (void *)((char *)ptr + sizeof(raw_block_header_t));
+                }
             }
 #endif /* BITMAP_RB_ONLY */
         }