package memprof-limits

  1. Overview
  2. Docs

Source file memprof_limits.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
27
28
29
30
(* Copyright (c) 2020-2025, Guillaume Munch-Maccagnoni & INRIA
   SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
*)

let start_memprof_limits = Memprof_server.ensure_memprof_limits_started

let set_global_memory_limit l = Limits_callbacks.global_limit := l

let limit_global_memory f =
  Memprof_server.ensure_memprof_limits_started ();
  Limits_callbacks.limit_global_memory ~f

let limit_allocations ~limit f =
  Memprof_server.ensure_memprof_limits_started ();
  Limits_callbacks.limit_allocations ~limit ~f

let max_allocation_limit = Limits_callbacks.max_allocation_limit

let limit_with_token ~token f =
  Memprof_server.ensure_memprof_limits_started ();
  Limits_callbacks.limit_with_token ~token ~f

let is_interrupted = Limits_callbacks.is_interrupted

type 'a result = ('a, exn) Result.t

module Token = Token
module Masking = Masking
module Resource_bind = Resource_bind
module Memprof = Memprof