Skip to main content
Glama

get_memory_timeline

Retrieve memory usage timeline data from PHP application profiling to analyze memory consumption patterns during execution.

Instructions

Get memory usage timeline from profiling

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registers the 'get_memory_timeline' MCP tool with empty input schema. The inline handler fetches the memory timeline from the Profiler instance and returns a formatted JSON response.
    server.tool( 'get_memory_timeline', 'Get memory usage timeline from profiling', {}, async () => { const timeline = ctx.profiler.getMemoryTimeline(); return { content: [ { type: 'text', text: JSON.stringify( { timeline: timeline.map((t) => ({ timestamp: t.timestamp, usage: Profiler.formatBytes(t.usage), peak: Profiler.formatBytes(t.peak), })), }, null, 2 ), }, ], }; } );
  • Core handler logic in Profiler.getMemoryTimeline() that filters snapshots with memory data and maps them to timeline entries with timestamp, usage, and peak memory.
    getMemoryTimeline(): Array<{ timestamp: Date; usage: number; peak: number }> { if (!this.currentSession) return []; return this.currentSession.snapshots .filter((s) => s.memoryUsage !== undefined) .map((s) => ({ timestamp: s.timestamp, usage: s.memoryUsage!, peak: s.peakMemoryUsage || s.memoryUsage!, })); }
  • Static utility method Profiler.formatBytes() used by the tool handler to format raw byte values into human-readable strings (B, KB, MB, GB).
    static formatBytes(bytes: number): string { if (bytes < 1024) return `${bytes} B`; if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)} KB`; if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(2)} MB`; return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kpanuragh/xdebug-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server