memtrace

Instrument OCaml builds with memtrace to collect and compare allocation traces.

35|9|Updated Dec 25, 2025
One-click install
npx skills add https://github.com/avsm/ocaml-claude-marketplace --skill memtrace-avsm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memtrace
Source: https://github.com/avsm/ocaml-claude-marketplace/tree/main/plugins/ocaml-dev/skills/memtrace
Command: npx skills add https://github.com/avsm/ocaml-claude-marketplace --skill memtrace-avsm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Memtrace profiling helps OCaml developers pinpoint allocation hotspots and boxing overhead so performance can be improved without broad, guesswork optimizations.

Core Features & Use Cases

  • Instrument OCaml executables to collect allocation traces and identify hotspot sites
  • Detect boxing-heavy paths (e.g., int32/int64 or floats in arrays) and optimize them
  • Validate optimizations by re-running targeted benchmarks and comparing before/after traces

Quick Start

Set MEMTRACE=trace.ctf and run your OCaml executable or tests with dune to generate a trace, then view the results with memtrace-viewer.

Frequently Asked Questions about memtrace

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I profile OCaml allocation hotspots?

Identify allocation hotspots in OCaml programs by instrumenting builds with memtrace to collect trace data. Apply this to tests and benchmarks targeting hot paths such as parsing, serialization, and boxing-heavy code to compare before/after traces.

What causes boxing overhead in OCaml and how do I detect it?

Boxing-heavy paths involving int32, int64, or floats in arrays cause allocation overhead. Detect these sites by collecting memtrace traces on targeted benchmarks and analyzing the hotspot data before applying optimizations.

How do I validate OCaml performance optimizations after refactoring?

Validate optimizations by re-running targeted benchmarks and comparing before/after memtrace traces. This confirms that changes to hot paths like parsing, serialization, and boxing-heavy code successfully reduced allocation hotspots.

Do I need to modify dune test configurations to use memtrace?

Yes, you must configure dune tests and insert Memtrace.trace_if_requested at program startup. This setup ensures allocation traces are collected when your OCaml tests and benchmarks are executed.