Skip to main content
Glama

get_memory_timeline

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

Instructions

Get memory usage timeline from profiling

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "properties": {}, "type": "object" }

Implementation Reference

  • The MCP tool registration and inline handler for 'get_memory_timeline'. It retrieves the memory timeline from the profiler context and returns a formatted JSON response with timestamp, usage, and peak memory.
    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 ), }, ], }; } );
  • The Profiler class method getMemoryTimeline() that filters and maps snapshots to create the memory usage timeline array used by the tool handler.
    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 in the tool handler to format memory bytes into human-readable strings.
    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