summaryrefslogtreecommitdiff
path: root/stdlib/gc.ml
diff options
context:
space:
mode:
authorJacques-Henri Jourdan <jacques-henri.jourdan@normalesup.org>2019-04-23 09:27:31 +0200
committerJacques-Henri Jourdan <jacques-henri.jourdan@normalesup.org>2019-05-09 16:40:45 +0200
commit052a950deaa739139870f660ea53c6ce2b060f3e (patch)
tree99c6624705d9b9f8da0158464fc017685b935e9d /stdlib/gc.ml
parent89b1ab4acacc9266aa6f6df6bb86f43310825447 (diff)
downloadocaml-052a950deaa739139870f660ea53c6ce2b060f3e.tar.gz
Statistical memory profiling of blocks allocated in the major heap.
Diffstat (limited to 'stdlib/gc.ml')
-rw-r--r--stdlib/gc.ml36
1 files changed, 34 insertions, 2 deletions
diff --git a/stdlib/gc.ml b/stdlib/gc.ml
index 41a8f8c8fa..28beaf66c5 100644
--- a/stdlib/gc.ml
+++ b/stdlib/gc.ml
@@ -3,9 +3,10 @@
(* OCaml *)
(* *)
(* Damien Doligez, projet Para, INRIA Rocquencourt *)
+(* Jacques-Henri Joudan, projet Gallium, INRIA Paris *)
(* *)
-(* Copyright 1996 Institut National de Recherche en Informatique et *)
-(* en Automatique. *)
+(* Copyright 1996-2016 Institut National de Recherche en Informatique *)
+(* et en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
@@ -117,3 +118,34 @@ let create_alarm f =
let delete_alarm a = a := false
+
+module Memprof =
+ struct
+ type alloc_kind =
+ | Minor
+ | Major
+ | Serialized
+
+ type sample_info = {
+ n_samples: int; kind: alloc_kind; tag: int;
+ size: int; callstack: Printexc.raw_backtrace;
+ }
+
+ type 'a callback = sample_info -> (Obj.t, 'a) Ephemeron.K1.t option
+
+ type 'a ctrl = {
+ sampling_rate : float;
+ callstack_size : int;
+ callback : 'a callback
+ }
+
+ let stopped_ctrl = {
+ sampling_rate = 0.; callstack_size = 0;
+ callback = fun _ -> assert false
+ }
+
+ external set_ctrl : 'a ctrl -> unit = "caml_memprof_set"
+
+ let start = set_ctrl
+ let stop () = set_ctrl stopped_ctrl
+ end