package mem_usage
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=6c5036811ec7240f659dcd8f764cf382
sha512=98062df94ad6df4c6d6925b26105d83064af658498545fc39d573e9b6441be03c29731bad55ab5aeeab26924520a7378803685f590d2cab359e1a72c282d1193
doc/README.html
ocaml-mem_usage
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 RAM installed on the system |
| Total virtual memory (RAM + swap) |
| RAM currently in use system-wide |
| Virtual memory in use system-wide |
| Virtual address space of the process |
| Resident set size (RSS) - pages in RAM |
| Private pages unique to this process (USS) |
| 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 MiBInstallation
opam install mem_usageTo install from source:
git clone https://github.com/savonet/ocaml-mem_usage.git
cd ocaml-mem_usage
opam install .Documentation
License
MIT