Debugging and Profiling OCaml – lessons (re)learned

Don’t forget

  • Use Valgrind to debug memory corruption.
    • Symptoms: random crashes in garbage collection, in ctypes code, in system libraries etc.
    • Example invocation: valgrind --leak-check=full --leak-resolution=high --show-leak-kinds=all --errors-for-leak-kinds=none _build/default/bin/example.exe
  • Use GDB when the program hangs to quickly see the stack trace.
  • If you use landmarks to compare performances of parts within a program run: it seems that the optional wallclock timer is not reset properly between restarts.