Module Memprof_limits.Memprof

This is a reimplementation of Gc.Memprof on top of Memprof-limits, with the same interface. (Its signature is included in particular in module type of Stdlib__Gc.Memprof.)

Generally, one must not use Memprof-limits and Gc.Memprof on the same domain. Instead, you can use the present module if you need to profile a domain that simultaneously uses Memprof-limits. It is also possible to use Gc.Memprof and Memprof-limits simultaneously inside distinct domain hierarchies.

This module is experimental. In addition, from OCaml 5.3 to OCaml < 5.5, this module was not fully implemented; it only worked in simple-enough situations.

Note: the expectancy (1/sampling_rate) provided in Memprof.start is rounded to the nearest integer for the accuracy of allocation limits accounting. The sampling rate must also not be lower than the default sampling rate of Memprof-limits.

type t
type allocation_source = Stdlib.Gc.Memprof.allocation_source =
  1. | Normal
  2. | Marshal
  3. | Custom
type allocation = private Stdlib.Gc.Memprof.allocation = {
  1. n_samples : int;
  2. size : int;
  3. source : allocation_source;
  4. callstack : Stdlib.Printexc.raw_backtrace;
}
type (!'minor, !'major) tracker = ('minor, 'major) Stdlib.Gc.Memprof.tracker = {
  1. alloc_minor : allocation -> 'minor option;
  2. alloc_major : allocation -> 'major option;
  3. promote : 'minor -> 'major option;
  4. dealloc_minor : 'minor -> unit;
  5. dealloc_major : 'major -> unit;
}
val null_tracker : ('minor, 'major) tracker
val start : sampling_rate:float -> ?callstack_size:int -> ('minor, 'major) tracker -> t
val stop : unit -> unit
val discard : t -> unit