diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-03-03 20:25:07 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-03-03 20:25:07 +0300 |
commit | dbf1d2e9b106902333712e49be4e6e21edb8a421 (patch) | |
tree | 4e4d7fceb6ed84c2e944354e2a9cd31b82f94b42 /alloc.c | |
parent | 53997addf27a6f983ba55cf4c370d7685f8ad198 (diff) | |
download | bdwgc-dbf1d2e9b106902333712e49be4e6e21edb8a421.tar.gz |
Print in-use heap statistic on heap growth
* alloc.c (GC_DBGLOG_PRINT_HEAP_IN_USE): New macro (copy code from
GC_finish_collection).
* alloc.c (GC_finish_collection): Use GC_DBGLOG_PRINT_HEAP_IN_USE()
instead of relevant GC_DBGLOG_PRINTF().
* alloc.c (GC_expand_hp_inner): Call GC_DBGLOG_PRINT_HEAP_IN_USE()
(before the actual heap expansion).
Diffstat (limited to 'alloc.c')
-rw-r--r-- | alloc.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -1099,6 +1099,12 @@ GC_INLINE int GC_compute_heap_usage_percent(void) (int)((used * 100) / heap_sz) : (int)(used / (heap_sz / 100)); } +#define GC_DBGLOG_PRINT_HEAP_IN_USE() \ + GC_DBGLOG_PRINTF("In-use heap: %d%% (%lu KiB pointers + %lu KiB other)\n", \ + GC_compute_heap_usage_percent(), \ + TO_KiB_UL(GC_composite_in_use), \ + TO_KiB_UL(GC_atomic_in_use)) + /* Finish up a collection. Assumes mark bits are consistent, lock is */ /* held, but the world is otherwise running. */ STATIC void GC_finish_collection(void) @@ -1211,10 +1217,7 @@ STATIC void GC_finish_collection(void) COMMA_IF_USE_MUNMAP(TO_KiB_UL(GC_unmapped_bytes)), TO_KiB_UL(GC_our_mem_bytes - GC_heapsize + sizeof(GC_arrays))); - GC_DBGLOG_PRINTF("In-use heap: %d%% (%lu KiB pointers + %lu KiB other)\n", - GC_compute_heap_usage_percent(), - TO_KiB_UL(GC_composite_in_use), - TO_KiB_UL(GC_atomic_in_use)); + GC_DBGLOG_PRINT_HEAP_IN_USE(); if (GC_is_full_gc) { GC_used_heap_size_after_full = USED_HEAP_SIZE; GC_need_full_gc = FALSE; @@ -1522,6 +1525,7 @@ GC_INNER GC_bool GC_expand_hp_inner(word n) GC_ASSERT(GC_page_size != 0); if (0 == n) n = 1; bytes = ROUNDUP_PAGESIZE((size_t)n * HBLKSIZE); + GC_DBGLOG_PRINT_HEAP_IN_USE(); if (GC_max_heapsize != 0 && (GC_max_heapsize < (word)bytes || GC_heapsize > GC_max_heapsize - (word)bytes)) { |