static int n_partial_gcs = 0;
if (GC_should_collect()) {
+ if (GC_notify_event)
+ GC_notify_event (GC_EVENT_START);
+
+
if (!GC_incremental) {
GC_gcollect_inner();
n_partial_gcs = 0;
GC_n_attempts++;
}
}
+
+
+ if (GC_notify_event)
+ GC_notify_event (GC_EVENT_END);
}
}
# if defined(CONDPRINT) && !defined(PRINTTIMES)
if (GC_print_stats) GET_TIME(start_time);
# endif
+
# if defined(REGISTER_LIBRARIES_EARLY)
GC_cond_register_dynamic_libraries();
# endif
STOP_WORLD();
IF_THREADS(GC_world_stopped = TRUE);
+
+ if (GC_notify_event)
+ GC_notify_event (GC_EVENT_MARK_START);
+
# ifdef CONDPRINT
if (GC_print_stats) {
GC_printf1("--> Marking for collection %lu ",
(*GC_check_heap)();
}
+
+ if (GC_notify_event)
+ GC_notify_event (GC_EVENT_MARK_END);
+
IF_THREADS(GC_world_stopped = FALSE);
START_WORLD();
# ifdef PRINTTIMES
}
}
+void (*GC_notify_event) GC_PROTO((GCEventType e));
+void (*GC_on_heap_resize) GC_PROTO((size_t new_size));
+
/* Finish up a collection. Assumes lock is held, signals are disabled, */
/* but the world is otherwise running. */
void GC_finish_collection()
GET_TIME(start_time);
finalize_time = start_time;
# endif
+
+
+ if (GC_notify_event)
+ GC_notify_event (GC_EVENT_RECLAIM_START);
# ifdef GATHERSTATS
GC_mem_found = 0;
GC_print_address_map();
}
# endif
+
COND_DUMP;
if (GC_find_leak) {
/* Mark all objects on the free list. All objects should be */
# ifdef USE_MUNMAP
GC_unmap_old();
# endif
+
+ if (GC_notify_event)
+ GC_notify_event (GC_EVENT_RECLAIM_END);
+
# ifdef PRINTTIMES
GET_TIME(done_time);
GC_printf2("Finalize + initiate sweep took %lu + %lu msecs\n",
if (GC_collect_at_heapsize < GC_heapsize /* wrapped */)
GC_collect_at_heapsize = (word)(-1);
# endif
+ if (GC_on_heap_resize)
+ GC_on_heap_resize (GC_heapsize);
+
return(TRUE);
}
/* How many consecutive GC/expansion failures? */
/* Reset by GC_allochblk. */
+static word last_fo_entries = 0;
+static word last_words_finalized = 0;
+
GC_bool GC_collect_or_expand(needed_blocks, ignore_off_page)
word needed_blocks;
GC_bool ignore_off_page;
{
if (!GC_incremental && !GC_dont_gc &&
- (GC_dont_expand && GC_words_allocd > 0 || GC_should_collect())) {
+ (GC_dont_expand && GC_words_allocd > 0
+ || (GC_fo_entries > (last_fo_entries + 500) && (last_words_finalized || GC_words_finalized))
+ || GC_should_collect())) {
GC_gcollect_inner();
+ last_fo_entries = GC_fo_entries;
+ last_words_finalized = GC_words_finalized;
} else {
word blocks_to_get = GC_heapsize/(HBLKSIZE*GC_free_space_divisor)
+ needed_blocks;