📦 Other & Niche

Memory Profiler CLI

📁 Other & Niche 👤 Contributed by @f 🗓️ Updated
The prompt
Develop a memory profiling tool in C for analyzing process memory usage. Implement process attachment with minimal performance impact. Add heap analysis with allocation tracking. Include memory leak detection with stack traces. Implement memory usage visualization with detailed statistics. Add custom allocator hooking for detailed tracking. Include report generation in multiple formats. Implement filtering options for noise reduction. Add comparison functionality between snapshots. Include command-line interface with interactive mode. Implement signal handling for clean detachment.

Example outputs

Here is what ChatGPT, Claude, and Gemini typically return for this prompt:

🚀 ChatGPT

I'll help you create a memory profiling tool in C with the features you've specified. The implementation will use ptrace() for process attachment, malloc hooks for allocation tracking, and libunwind for stack traces. For the CLI, we'll use getopt_long() for argument parsing and implement an interactive mode with commands like 'snapshot', 'diff', and 'report'. The tool will support JSON, CSV, and human-readable output formats, with configurable thresholds to filter out small allocations.

✨ Claude

This is a substantial systems programming project that requires careful consideration of several tradeoffs. Process attachment via ptrace() can introduce overhead, so you'll want to implement selective tracing. For allocation tracking, interposing malloc/free is more reliable than hooking, though it limits you to dynamic linking scenarios. Stack trace collection with libunwind adds significant overhead—consider making it optional or sampling-based for production use.

💎 Gemini

A C-based memory profiler would typically use LD_PRELOAD to intercept malloc/free calls, ptrace for external process attachment, and libraries like libunwind or libbacktrace for stack traces. Key implementation concerns include thread-safety (use pthread mutexes around tracking structures), minimal overhead (ring buffers for event logging), and proper signal handling (SIGINT, SIGTERM) for graceful shutdown. Popular tools like Valgrind's massif and heaptrack demonstrate effective approaches to heap profiling and leak detection.

How to use this prompt

Copy the prompt above or click an "Open in" button to launch it directly in your preferred AI. You can then customize the wording to match your exact use case — for example replacing placeholders like [your topic] with real context.

Which AI model works best

ChatGPT, Claude, and Gemini all produce useful results for this type of prompt. Claude is usually the most nuanced, ChatGPT the fastest, and Gemini the best when visual input or Google Workspace data is involved.

How to customize this prompt

Adapt the prompt to your specific use case. Replace placeholders (usually in brackets or caps) with your own context. The more detail you provide, the more precise the response.

Common use cases

  • Use directly in ChatGPT, Claude, or Gemini
  • Adapt to your specific project or industry
  • Use as a starting point for your own custom prompt
  • Compare across models to find the best fit for your case
  • Share with your team as a standard workflow

Variations

Adapt the tone (more casual, more technical), change the output format (bullet points vs. paragraphs), or add constraints (word limits, target audience).

Related prompts