Hello,
It looks like functions registered by Gc.create_alarm are no longer called in Ocaml 5.2.0.
This code used to exit 123 with 5.1.0 but terminates normally in 5.2.0:
let () =
let _ = Gc.create_alarm (fun () -> Format.printf "Alarm@."; exit 123)
in
let g = Array.init 120000 (fun i -> Array.init 1 (fun i -> i)) in
for i = 0 to 10000 do
let a = Array.init 120000 (fun i -> i) in
g.(i) <- a;
a.(0) <- 42;
done
The following command ocamlopt a.ml && OCAMLRUNPARAM=v=0x403 ./a.out displays
For Ocaml 4.14.1: Gc cycles are displayed and alarm is called
<>Starting new major GC cycle
<><>!Alarm
allocated_words: 252056
minor_words: 132055
promoted_words: 131877
major_words: 251878
minor_collections: 3
major_collections: 0
heap_words: 311296
heap_chunks: 4
top_heap_words: 311296
compactions: 0
forced_major_collections: 0
For Ocaml 5.1.0: Gc cycles are NOT displayed and alarm is called
Alarm
allocated_words: 120857
minor_words: 790
promoted_words: 603
major_words: 120670
minor_collections: 8
major_collections: 7
forced_major_collections: 0
heap_words: 165059
top_heap_words: 165059
mean_space_overhead: 10211.522634
For Ocaml 5.2.0: No GC cycle displayed and no alarm triggered
allocated_words: 1200490800
minor_words: 240732
promoted_words: 240619
major_words: 1200490687
minor_collections: 28
major_collections: 24
forced_major_collections: 0
heap_words: 1099274194
top_heap_words: 1099274194
mean_space_overhead: 0.022869
Is this expected? The 5.2.0 Changelog mentions that the behavior of alarms changed, but it looks like they are no longer working at all in this example.
The differences in the Gc activity displayed with v=0x3 seems undocumented too and is probably not reflecting the real activity of the Gc.
Thanks for your help!
B.