CAMLprim value caml_gc_compaction(value v) { Assert (v == Val_unit); caml_empty_minor_heap (); caml_finish_major_cycle (); caml_finish_major_cycle (); caml_compact_heap (); caml_final_do_calls (); return Val_unit; }
CAMLprim value caml_gc_compaction(value v) { Assert (v == Val_unit); caml_gc_message (0x10, "Heap compaction requested\n", 0); caml_empty_minor_heap (); caml_finish_major_cycle (); caml_final_do_calls (); caml_empty_minor_heap (); caml_finish_major_cycle (); caml_compact_heap (); caml_final_do_calls (); return Val_unit; }
static void test_and_compact (void) { float fp; fp = 100.0 * caml_fl_cur_wsz / (caml_stat_heap_wsz - caml_fl_cur_wsz); if (fp > 999999.0) fp = 999999.0; caml_gc_message (0x200, "Estimated overhead (lower bound) = %" ARCH_INTNAT_PRINTF_FORMAT "u%%\n", (uintnat) fp); if (fp >= caml_percent_max && caml_stat_heap_chunks > 1){ caml_gc_message (0x200, "Automatic compaction triggered.\n", 0); caml_compact_heap (); } }
CAMLprim value caml_gc_compaction(value v) { CAML_INSTR_SETUP (tmr, ""); Assert (v == Val_unit); caml_gc_message (0x10, "Heap compaction requested\n", 0); caml_empty_minor_heap (); caml_finish_major_cycle (); caml_final_do_calls (); caml_empty_minor_heap (); caml_finish_major_cycle (); caml_compact_heap (); caml_final_do_calls (); CAML_INSTR_TIME (tmr, "explicit/gc_compact"); return Val_unit; }
static void test_and_compact (void) { uintnat fp; fp = (100 * caml_fl_cur_size) / (Wsize_bsize (caml_stat_heap_size) - caml_fl_cur_size); if (fp > 999999) fp = 999999; caml_gc_message (0x200, "Estimated overhead (lower bound) = %" ARCH_INTNAT_PRINTF_FORMAT "u%%\n", (uintnat) fp); if (fp >= caml_percent_max && caml_stat_heap_chunks > 1){ caml_gc_message (0x200, "Automatic compaction triggered.\n", 0); caml_compact_heap (); } }
void caml_compact_heap_maybe (void) { /* Estimated free words in the heap: FW = fl_size_at_change + 3 * (caml_fl_cur_size - caml_fl_size_at_phase_change) FW = 3 * caml_fl_cur_size - 2 * caml_fl_size_at_phase_change Estimated live words: LW = caml_stat_heap_size - FW Estimated free percentage: FP = 100 * FW / LW We compact the heap if FP > caml_percent_max */ uintnat fw, fp; Assert (caml_gc_phase == Phase_idle); if (caml_percent_max >= 1000000) return; if (caml_stat_major_collections < 3 || caml_stat_heap_chunks < 3) return; fw = 3 * caml_fl_cur_size - 2 * caml_fl_size_at_phase_change; if (fw < 0) fw = caml_fl_cur_size; if (fw >= Wsize_bsize (caml_stat_heap_size)){ fp = 1000000; }else{ fp = 100 * fw / (Wsize_bsize (caml_stat_heap_size) - fw); if (fp > 1000000) fp = 1000000; } caml_gc_message (0x200, "FL size at phase change = %" ARCH_INTNAT_PRINTF_FORMAT "u\n", caml_fl_size_at_phase_change); caml_gc_message (0x200, "Estimated overhead = %" ARCH_INTNAT_PRINTF_FORMAT "u%%\n", fp); if (fp >= caml_percent_max){ caml_gc_message (0x200, "Automatic compaction triggered.\n", 0); caml_finish_major_cycle (); /* We just did a complete GC, so we can measure the overhead exactly. */ fw = caml_fl_cur_size; fp = 100 * fw / (Wsize_bsize (caml_stat_heap_size) - fw); caml_gc_message (0x200, "Measured overhead: %" ARCH_INTNAT_PRINTF_FORMAT "u%%\n", fp); caml_compact_heap (); } }