package xenstore

  1. Overview
  2. Docs

Source file heap_debug_interface.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
include Namespace.Unsupported

let debug fmt = Logging.debug "memory_interface" fmt
let ( |> ) a b = b a

let read _t (perms : Perms.t) (path : Store.Path.t) =
  Perms.has perms Perms.CONFIGURE;
  match Store.Path.to_string_list path with
  | [] -> ""
  | "heap_words" :: [] -> string_of_int (Gc.stat ()).Gc.heap_words
  | "live_words" :: [] -> string_of_int (Gc.stat ()).Gc.live_words
  | "free_words" :: [] -> string_of_int (Gc.stat ()).Gc.free_words
  | "symbols" :: [] -> string_of_int (Symbol.stats ())
  | _ -> Store.Path.doesnt_exist path

let exists t perms path =
  try
    ignore (read t perms path);
    true
  with Store.Path.Doesnt_exist _ -> false

let list _t perms path =
  Perms.has perms Perms.CONFIGURE;
  match Store.Path.to_string_list path with
  | [] -> [ "heap_words"; "live_words"; "free_words"; "symbols" ]
  | _ -> []
OCaml

Innovation. Community. Security.