(* Step 6: the OCaml GC beside Flan's arenas. Allocate hard, then compact -- the most disruptive thing the collector does, since compaction is what actually moves blocks. C checks its arena after. *) external note : nativeint -> unit = "spike_note_arena" let () = Callback.register "spike_churn" (fun (rounds : int) -> let keep = ref [] in for i = 1 to rounds do (* Garbage, plus a little that survives, so the heap really grows. *) for _ = 1 to 2000 do ignore (Bytes.create 512) done; if i mod 10 = 0 then keep := Bytes.create 4096 :: !keep done; Gc.full_major (); Gc.compact (); let s = Gc.quick_stat () in Printf.sprintf "allocated %.0f words, %d major collections, %d compactions, heap %d words" s.Gc.minor_words s.Gc.major_collections s.Gc.compactions s.Gc.heap_words); ignore note