From: Paolo Molaro Date: Mon, 24 Jan 2005 15:29:23 +0000 (+0000) Subject: Add on-heap-resize event notification to API X-Git-Tag: gc7_3alpha2~223 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c9c95c1c02744d1909eebdc45f17cb278d4fe2d;p=gc Add on-heap-resize event notification to API (Apply part of commit 3f1314a from 'mono_libgc' branch) * include/gc.h (GC_on_heap_resize): New API variable declaration. * alloc.c (GC_on_heap_resize): New global variable. * alloc.c (GC_finish_collection): Invoke GC_on_heap_resize (if non-zero) on returning true. --- diff --git a/alloc.c b/alloc.c index e182af2e..6131a384 100644 --- a/alloc.c +++ b/alloc.c @@ -780,6 +780,8 @@ STATIC void GC_clear_fl_marks(ptr_t q) void GC_check_tls(void); #endif +void (*GC_on_heap_resize)(size_t new_size) = 0; + /* Finish up a collection. Assumes mark bits are consistent, lock is */ /* held, but the world is otherwise running. */ STATIC void GC_finish_collection(void) @@ -1172,6 +1174,9 @@ GC_INNER GC_bool GC_expand_hp_inner(word n) GC_heapsize + expansion_slop - 2*MAXHINCR*HBLKSIZE; if (GC_collect_at_heapsize < GC_heapsize /* wrapped */) GC_collect_at_heapsize = (word)(-1); + if (GC_on_heap_resize) + (*GC_on_heap_resize)((size_t)GC_heapsize); + return(TRUE); } diff --git a/include/gc.h b/include/gc.h index 27033dce..355f3026 100644 --- a/include/gc.h +++ b/include/gc.h @@ -113,6 +113,9 @@ GC_API GC_oom_func GC_oom_fn; GC_API void GC_CALL GC_set_oom_fn(GC_oom_func); GC_API GC_oom_func GC_CALL GC_get_oom_fn(void); +GC_API void (*GC_on_heap_resize)(size_t /* new_size */); + /* Invoked when the heap grows or shrinks */ + GC_API int GC_find_leak; /* Do not actually garbage collect, but simply */ /* report inaccessible memory that was not */