package memprof-limits

  1. Overview
  2. Docs
Memory limits, allocation limits, and thread cancellation

Install

dune-project
 Dependency

Authors

Maintainers

Sources

memprof-limits-v0.3.0.tar.gz
md5=39c73e7f96b5e5a01cf74937e2a5a1ae
sha512=a0049fec23c054eef19a924e5be810ecf9de4f697bd09b133e64c244b7ea09f416cec627ccce412ae793c265043894a878f0d822bcc47a2e622526f96d14af25

Description

Memprof-limits provides per-thread global memory limits, per-thread allocation limits, and cancellation of threads, with ways to ensure resource-safety after interruption.

Global memory limits let you bound the memory consumption of a task, in terms of the major heap size.

Allocation limits let you bound the execution time of a task measured in number of allocations. Allocation limits do not count deallocations, and are therefore a measure of the work done, which can be more suitable (reliable, portable, deterministic) than wall-clock time.

Token limits lets you cancel a (CPU-bound) task preemptively and at a distance.

Tasks are interrupted by raising an asynchronous exception. Memprof-limits provides resource-management features and guidance for reasoning about the consistency of state in the presence of such interrupts.

The implementation uses OCaml's Statmemprof engine with a low sampling rate that does not affect performance. Memprof cannot be used on the same domain as memprof-limits, but a compatible reimplementation of the Memprof interface is provided for your profiling needs.

Published: 05 Sep 2025

README

Memprof-limits — Memory limits, allocation limits, and thread cancellation for OCaml

Memprof-limits is an implementation of (per-thread) global memory limits, (per-thread) allocation limits, and cancellation of CPU-bound threads, for OCaml. Memprof-limits interrupts a computation by raising an exception asynchronously and offers features to recover from them such as interrupt-safe resources.

The implementation uses OCaml's Memprof engine with a low sampling rate that does not affect performance. A reimplementation of the Gc.Memprof module is also provided for the purpose of profiling without interfering with interrupts.

To help the programmer implement the recovery from a memprof-limits interrupts, resource-management facilities and a detailed explanation are provided with this software. This documentation summarises the experience acquired in the Rocq prover, as well as in other programming languages.

Memprof-limits supports OCaml 5 (starting from 5.3) but full support for profiling with the Memprof_limits.Memprof reimplementation of Gc.Memprof requires OCaml ≥ 5.5.

  • Home page: https://gitlab.com/gadmm/memprof-limits/
  • Documentation: https://guillaume.munch.name/software/ocaml/memprof-limits/
  • Changes: https://gitlab.com/gadmm/memprof-limits/-/blob/master/CHANGES.md

Memprof-limits is distributed under the LGPL license version 3 with linking exception, see LICENSE.

Installation

Memprof-limits can be installed with Opam: opam install memprof-limits. It requires OCaml 4.12 or newer for OCaml 4, and OCaml 5.3 or newer for OCaml 5.

Compilation from sources is done with make. Testing is done with make test.

Building the documentation

  • Building the documentation with graphs requires odoc and odoc-driver and involves the following steps:

    • Compile and install memprof-limits in the current opam switch: opam install --working-dir .
    • Compile the documentation with odoc-driver: odoc_driver --remap memprof-limits
    • The documentation is then available in the _html/ subdir.
  • Building the documentation with make doc uses odoc via dune and does not support graphs. The documentation is then available at _build/default/_doc/_html.

Documentation

Dependencies (3)

  1. cppo build
  2. dune >= "1.2"
  3. ocaml (>= "4.12.0" & < "5.0") | >= "5.3"

Dev Dependencies (1)

  1. odoc with-doc

Used by (1)

  1. coq-lsp >= "0.1.9+8.17"

Conflicts

None

OCaml

Innovation. Community. Security.