At first sight, threads and signals would mess with the minor heap in hard to predict ways.
Then, it would work only if
Toto.create does not allocate anything at all but the data that will eventually be reachable from the result (which seams unlikely), and that it does only allocate on ocaml heap, and that it does not trigger the Gc for any other reason.
Also, it would help to enlarge the default minor heap size (OCAMLRUNPARAM=s=100M ?) and to call Gc.minor first.
If all the above conditions are met then I would also expect this to work, including in native code compiled programs.
But to met all those conditions is hard. It took me a while to find a suitable exemple in the program I’m currently working on, and I eventually settled on a mere
let some_empty_hash =
let before = Gc.minor_words () in
let x = ref (Hashtbl.create 11) in
let after = Gc.minor_words () in
Printf.printf "Size of Hashtbl(11) = %g - %g = %g\n%!" after before (after -. before) ;
This convincingly printed:
Size of Hashtbl(11) = 205878 - 205852 = 26