package mem_usage

  1. Overview
  2. Docs
Cross-platform stats about memory usage

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.2.0.tar.gz
md5=6c5036811ec7240f659dcd8f764cf382
sha512=98062df94ad6df4c6d6925b26105d83064af658498545fc39d573e9b6441be03c29731bad55ab5aeeab26924520a7378803685f590d2cab359e1a72c282d1193

doc/README.html

ocaml-mem_usage

GitHub GitHub Workflow Status GitHub release (latest by date)

A cross-platform OCaml module for reporting memory usage, with a focus on distinguishing private memory (allocated by the process itself) from shared memory (e.g., shared libraries, memory-mapped files).

Overview

The module reports both system-wide and per-process memory statistics:

Field

Description

total_physical_memory

Total RAM installed on the system

total_virtual_memory

Total virtual memory (RAM + swap)

total_used_physical_memory

RAM currently in use system-wide

total_used_virtual_memory

Virtual memory in use system-wide

process_virtual_memory

Virtual address space of the process

process_physical_memory

Resident set size (RSS) - pages in RAM

process_private_memory

Private pages unique to this process (USS)

process_swapped_memory

Process pages swapped to disk

The key metric is process_private_memory which represents memory that would be freed if this process terminates, excluding shared libraries and other shared mappings.

Supported Platforms

  • Linux
  • macOS
  • Windows
  • FreeBSD

Example

let () =
  let info = Mem_usage.info () in
  Printf.printf "Process private memory: %s\n"
    (Mem_usage.prettify_bytes ~binary:true info.process_private_memory)

Output:

Process private memory: 1.25 MiB

Installation

opam install mem_usage

To install from source:

git clone https://github.com/savonet/ocaml-mem_usage.git
cd ocaml-mem_usage
opam install .

Documentation

API documentation

License

MIT