Performanceprompt onlyMedium

Memory Usage Optimizer

This loop automatically analyzes and optimizes the codebase to reduce memory consumption. It iteratively identifies high-memory components, applies targeted optimizations (e.g., caching, lazy loading, data structure improvements), and validates improvements using a memory benchmark until the desired target is achieved or the maximum iterations are reached.

← all loops
memoryperformanceoptimizationprofilingefficiency

Goal

Lower memory usage

How to Run

Initiate the loop by running the kickoff prompt in your coding environment. The agent will autonomously execute workflow steps, run memory checks after each iteration, and stop once the target is met or the iteration limit is reached.

  1. 01

    Prepare Environment

    Ensure your project has a working memory benchmark script or command that outputs current memory usage metrics.

  2. 02

    Run Kickoff Prompt

    Paste the kickoff prompt into your coding agent interface (Cursor, Claude Code, etc.) to start the optimization loop.

  3. 03

    Monitor Progress

    The agent will self-pace through workflow steps, running the check command after each action until the exit condition is met.

Workflow Steps

  1. 01

    Analyze current memory usage using the memory benchmark command to establish a baseline.

    Record initial memory usage metrics for comparison.

  2. 02

    Identify top memory-consuming modules or functions via profiling or log analysis.

    List components contributing most to memory overhead.

  3. 03

    Apply targeted optimizations such as caching strategy improvements, lazy loading, or replacing heavy data structures.

    Ensure changes are applied safely without breaking functionality.

  4. 04

    Re-run the memory benchmark to measure improvement.

    Compare new memory usage against previous results and target threshold.

  5. 05

    If target not met and iterations remain, return to step 2 for further optimization.

    Loop until exit condition or max iterations reached.

Kickoff Prompt

Start the "Memory Usage Optimizer" loop.

Goal: Lower memory usage
Max iterations: 10
Between iterations run: memory benchmark
Exit when: Memory usage meets or falls below the target threshold specified in the kickoff prompt


Start the Memory Usage Optimizer loop. First, run the 'memory benchmark' command to assess current memory usage. Then, identify the most memory-intensive parts of the codebase and apply one optimization (e.g., caching, lazy loading, efficient data structures). Re-run the benchmark to check progress. Continue this cycle up to 10 times or until memory usage meets the target of [X MB/percentage reduction].

Self-pace this loop. After each iteration, run `memory benchmark` and evaluate the output, and only continue if the exit condition is not met (Memory usage meets or falls below the target threshold specified in the kickoff prompt). Stop when the exit condition passes or 10 iterations are reached. Give a short status update each pass.

Guardrails

hardcoded
  • ·Do not modify core system or runtime libraries unless explicitly required and safe to do so.
  • ·Always create backups or use version control before applying memory optimizations.
  • ·Validate each optimization step to ensure it does not introduce functional regressions.
  • ·Prioritize optimizations that maintain or improve code readability and maintainability.

Flow Diagram

rendering…

Related loops — Performance