memtrace

Instrument OCaml executables with Memtrace to collect allocation traces for hotspot analysis.

46|6|Updated Jan 28, 2026
One-click install
npx skills add https://github.com/aresbit/MateBot --skill memtrace
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memtrace
Source: https://github.com/aresbit/MateBot/tree/main/skills/ocaml/memtrace
Command: npx skills add https://github.com/aresbit/MateBot --skill memtrace

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

OCaml developers often struggle to understand where allocations and boxing occur, hindering performance improvements. This Skill provides a structured approach to instrument code with memtrace to reveal allocation hotspots and guide targeted optimizations.

Core Features & Use Cases

  • Instrument OCaml executables with memtrace to capture allocation traces.
  • Run targeted benchmarks to isolate hotspots, boxing overhead, and function hot paths.
  • Identify hotspot locations and validate optimizations with before/after comparisons.
  • Visualize traces with memtrace-viewer or hotspot tooling to drive data-informed improvements.

Quick Start

Use Memtrace to instrument your OCaml project: add Memtrace.trace_if_requested () at program startup, build with dune, run with MEMTRACE=trace.ctf, and analyze the resulting trace to locate allocation hotspots.

Frequently Asked Questions about memtrace

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

FAQPage Schema
How do I profile OCaml allocations to find performance hotspots?

You can profile OCaml allocations by adding Memtrace.trace_if_requested () at program startup, building with dune, running benchmarks with MEMTRACE=trace.ctf, and analyzing the resulting trace to locate allocation hotspots.

What is the best way to trace boxing overhead in OCaml benchmarks?

Tracing boxing overhead in OCaml is done by applying Memtrace instrumentation to targeted benchmarks, running them with the MEMTRACE environment variable enabled, and analyzing the trace data to isolate boxing overhead and function hot paths.

How do I validate OCaml performance optimizations with before and after comparisons?

You validate OCaml optimizations by running Memtrace-instrumented benchmarks before and after code changes, capturing allocation traces, and comparing hotspot data to confirm reductions in boxing overhead and allocations.

Can I use dune to build OCaml projects with Memtrace instrumentation?

Yes, you can use dune to build OCaml projects with Memtrace instrumentation by integrating the trace_if_requested call at startup and gating the trace collection using the MEMTRACE environment variable during benchmark execution.

How do I visualize Memtrace allocation data to guide code improvements?

Visualizing Memtrace allocation data involves loading the generated trace.ctf files into memtrace-viewer or similar hotspot tooling, which graphically displays function hot paths and boxing overhead to drive data-informed improvements.