Can't produce spacetime files with toy program

Hi all,

I’m trying to write a small toy ocaml program to be profiled with spacetime, but can’t manage to produce the expected spacetime-<mypid> file.

Here’s what I do:

  1. opam switch 4.05.0+spacetime
    eval $(opam config env)
  2. in a file main.ml:
type myrec = { s: string; x: int }

let () =
  (* let's allocate memory *)
  let x = { s = "hi"; x = 1 } in
  (* let's do useless computation so as not to die immediately. *)
  for i = 0 to 100000000 do
    (if i = 99 then Printf.printf "%d" i;)
  done;
  Printf.printf "%d" x.x;
  ()
  1. compile with
    ocamlfind ocamlc -o main main.ml -verbose
  2. run with
    OCAML_SPACETIME_INTERVAL=1 ./main

Expected: a spacetime-xxxx file is created in the working directory.
Real: no file is created.

What am I doing wrong?

Automatic snapshots can only be taken when the GC does a minor collection. It looks to me like your toy program probably doesn’t actually do any minor collections. Although I would have expected that to cause us to output an empty profile rather than no profile – although maybe I’m misremembering what I actually implemented.