memthol icon indicating copy to clipboard operation
memthol copied to clipboard

Memthol is a visualizer for memory profiling data generated from OCaml programs.

Memthol is a visualizer for memory profiling data generated from OCaml programs.

Resources

Features

  • [x] multi-client: open several tabs in your browser for the same profiling session to visualize the data separately
  • [x] self-contained: the BUI packs all its static assets, once you have the binary you do not need anything else (except a browser)
  • [x] data-splitting: plot several families of data separately in the same chart by separating them based on size, allocation lifetime, source locations in the allocation callstack, etc.
  • [ ] multiple metrics to plot different kinds of data: allocation lifetime, size, time of creation, etc.
  • [ ] flamegraphs

What It Looks Like

Browser Compatibility

Memthol is mostly tested on the Chrome web browser. You might experience problems with other browser, in which case we recommend you open an issue.

Dump Files

Memthol's current official input format is memory dumps produced by Memtrace (on github). A memtrace dump for a program execution is a single Common Trace Format (CTF) file.

Note that this repository contains a minimal Memtrace example in rsc/memtrace_example.

Build

Pre-requisites

Since memthol's UI is browser-based, it has a client written in Rust that compiles to web assembly (wasm). To do this, you need to have the rust toolchain.

  • add the wasm target for rustup:

    rustup target add wasm32-unknown-unknown
    
  • make sure everything is up to date with

    rustup update
    
  • make sure you have wasm-pack installed so that Rust can compile the client

    installation instructions here, although cargo install wasm-pack should work

  • install cargo-make with cargo install cargo-make

Memthol UI's dependencies rely on some OS-level packages. Please make sure they are installed and in your path:

  • build essentials (including cmake)
  • openssl/libssl
  • freetype
  • expat

debug

NB: memthol is quite slow in debug mode. If you have a lot of data to process, definitely build in release instead.

To build memthol in debug mode, run

cargo make build

The memthol binary will be in target/debug/memthol

release

To build memthol in release mode, run

cargo make release

The memthol binary will be in ./memthol_ui, also available as target/release/memthol.

Testing

Run memthol-ui on the test files located on this repository, in rsc/ctf/mini_ae.ctf to make sure it works. Assuming your binary is called memthol and is in you path, and you are at the root of this repository:

memthol rsc/dumps/ctf/mini_ae.ctf

There is a bigger set of data you can use for testing, although we recommend you build in release mode for this one:

memthol rsc/dumps/ctf/flambda.ctf

Icons

Most icons used in memthol come from the bootstrap library.