summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2021-09-22 21:18:53 +0300
committerIvan Maidanski <ivmai@mail.ru>2021-09-22 21:23:28 +0300
commit46bed17695d8b49206ee66739eec2e87098d001b (patch)
tree9e6e0bc805475dcdb3d2f8a9e48794325a3298b9 /tests
parentfb89ec67f424bf46f00b67acaced89bee56cbb17 (diff)
downloadbdwgc-46bed17695d8b49206ee66739eec2e87098d001b.tar.gz
Declare API function and print amount of memory obtained from OS
Public GC_get_obtained_from_os_bytes() is introduced. * alloc.c [USE_MUNMAP] (GC_stopped_mark): Add assertion that GC_heapsize is not less than GC_unmapped_bytes. * alloc.c (GC_stopped_mark): Add assertion that GC_our_mem_bytes is not less than GC_heapsize; print GC_our_mem_bytes-GC_heapsize value (using GC_DBGLOG_PRINTF). * alloc.c [USE_PROC_FOR_LIBRARIES] (GC_add_to_our_memory): Update comment; increment GC_our_mem_bytes value (by bytes). * include/private/gc_priv.h (GC_add_to_our_memory): Likewise. * include/gc.h (GC_get_obtained_from_os_bytes): New API function declaration. * include/gc.h (GC_prof_stats_s.obtained_from_os_bytes): Declare new field. * include/private/gc_priv.h (_GC_arrays._our_mem_bytes): Likewise. * misc.c (GC_get_obtained_from_os_bytes): Implement. * misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (fill_prof_stats): Set obtained_from_os_bytes field. * tests/test.c (check_heap_stats): Print value returned by GC_get_obtained_from_os_bytes(). * tests/test.c [USE_MUNMAP] (check_heap_stats): Print value returned by GC_get_unmapped_bytes().
Diffstat (limited to 'tests')
-rw-r--r--tests/test.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/test.c b/tests/test.c
index ab590fea..5e02b788 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -1830,6 +1830,14 @@ void check_heap_stats(void)
(unsigned long)max_heap_sz);
FAIL;
}
+# ifdef USE_MUNMAP
+ GC_printf("Obtained %lu bytes from OS (of which %lu bytes unmapped)\n",
+ (unsigned long)GC_get_obtained_from_os_bytes(),
+ (unsigned long)GC_get_unmapped_bytes());
+# else
+ GC_printf("Obtained %lu bytes from OS\n",
+ (unsigned long)GC_get_obtained_from_os_bytes());
+# endif
GC_printf("Final number of reachable objects is %u\n", obj_count);
# ifndef GC_GET_HEAP_USAGE_NOT_NEEDED