(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.
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)
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);
}
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 */