Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
CAMLprim value caml_gc_full_major(value v)
{   Assert (v == Val_unit);
    caml_gc_message (0x1, "Full major GC cycle requested\n", 0);
    caml_empty_minor_heap ();
    caml_finish_major_cycle ();
    caml_final_do_calls ();
    caml_empty_minor_heap ();
    caml_finish_major_cycle ();
    test_and_compact ();
    caml_final_do_calls ();
    return Val_unit;
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
CAMLprim value caml_gc_full_major(value v)
{
  CAML_INSTR_SETUP (tmr, "");
  Assert (v == Val_unit);
  caml_gc_message (0x1, "Full major GC cycle requested\n", 0);
  caml_empty_minor_heap ();
  caml_finish_major_cycle ();
  caml_final_do_calls ();
  caml_empty_minor_heap ();
  caml_finish_major_cycle ();
  test_and_compact ();
  caml_final_do_calls ();
  CAML_INSTR_TIME (tmr, "explicit/gc_full_major");
  return Val_unit;
}
Exemplo n.º 6
0
CAMLprim value caml_gc_major(value v)
{                                                    Assert (v == Val_unit);
  caml_gc_log ("Major GC cycle requested");
  caml_ev_pause(EV_PAUSE_GC);
  caml_empty_minor_heap ();
  caml_finish_major_cycle();
  caml_final_do_calls ();
  caml_ev_resume();
  return Val_unit;
}
Exemplo n.º 7
0
CAMLprim value caml_gc_full_major(value v)
{
  int i;
  caml_gc_log ("Full Major GC requested");
  caml_ev_pause(EV_PAUSE_GC);
  /* In general, it can require up to 3 GC cycles for a
     currently-unreachable object to be collected. */
  for (i = 0; i < 3; i++) {
    caml_empty_minor_heap();
    caml_finish_major_cycle();
    caml_final_do_calls ();
  }
  caml_ev_resume();
  return Val_unit;
}
Exemplo n.º 8
0
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 ();
  }
}