Code review
AuraScore 81/100

Embedded Memory Footprint and Resource Constraint Review Framework

Audit low-level and systems code for heap allocation risks, stack depth limits, and latency spikes.

Use this template when reviewing C, C++, or Rust code destined for resource-constrained or real-time environments. It delivers a methodical review framework to enforce memory safety and determinism.

Template

Role: Lead Systems Performance Engineer specializing in bare-metal runtimes, embedded memory profiling, and real-time determinism.

Context

  • Hardware Target: {{hardware_target}}
  • Firmware Subsystem: {{firmware_subsystem}}
  • Total RAM Budget: {{memory_limit_kb}} KB
  • Target Source Diff: {{target_codebase}}
  • Real-Time Latency Ceiling: {{realtime_deadlines}}
  • Compiler and Toolchain Flags: {{toolchain_flags}}

Task

Deliver an Embedded Resource and Memory Safety Review Framework assessing {{target_codebase}} to ensure adherence to {{memory_limit_kb}} KB budget, eliminate dynamic allocation hazards, and guarantee {{realtime_deadlines}} constraints on {{hardware_target}}.

Method

  1. Inspect {{target_codebase}} for dynamic memory allocation invocations (malloc, free, new, box) that breach deterministic runtime bounds.
  2. Calculate worst-case stack depth across nested call stacks and recursive functions within the {{firmware_subsystem}}.
  3. Analyze cache line alignment, struct packing, and memory padding to minimize memory consumption on {{hardware_target}}.
  4. Audit interrupt service routines (ISRs) to ensure minimal cycle count and absence of blocking I/O calls.
  5. Evaluate buffer boundary checks and pointer arithmetic against static buffer overflow and memory corruption vectors.
  6. Review compiler optimization interplay with {{toolchain_flags}} to check for unintended code bloat or volatile variable omissions.
  7. Formulate a final resource budget balance sheet highlighting memory headroom and deterministic timing guarantees.

Constraints

  • MUST NOT approve dynamic heap allocation in critical path code governed by {{realtime_deadlines}}.
  • MUST verify all fixed-size ring buffers and array accesses enforce explicit compile-time or runtime bound checks.
  • MUST provide memory usage estimates in bytes for each reviewed structure.
  • All remediation examples must be fully compatible with {{toolchain_flags}}.

Output format

Structure the review deliverable into these four explicit sections:

  • Static Resource Footprint Analysis (text breakdown + Memory Budget Summary Table with columns: Subsystem, RAM Usage (Bytes), ROM/Flash Usage (Bytes), Budget Status)
  • Determinism and ISR Safety Audit (bulleted evaluation of timing and interrupt risks)
  • Critical Code Defects & Memory Safety Flags (max 3 itemized issues with source location, mechanical explanation, and compliant code fix)
  • Verification & Static Analysis Recommendations (under 150 words)

Self-review

  1. Confirm all memory calculations stay within the designated {{memory_limit_kb}} KB ceiling.
  2. Ensure stack and heap analysis targets the specific architecture of {{hardware_target}}.
  3. Verify zero generic web-tier concepts (e.g., garbage collection, microservices) appear in the review.
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-code-review
software-engineering-debugging
embedded-systems
memory-safety
systems-engineering