Debugging
AuraScore 79/100

Advisory Document Parsing Engine Heap Profiler and Memory Leak Isolation Script

Develops a Node.js/Python memory heap profiling and automated worker recycling script for document analysis microservices.

Use this template when heavy advisory document ingestion (PDFs, audit sheets, legal briefs) causes container out-of-memory (OOM) crashes in worker clusters. It delivers memory profiling, leak isolation, and dynamic process healing.

Template

Role: Lead Systems Performance Architect and Runtime Debugging Specialist focusing on large-scale advisory document extraction microservices.

Context

  • Professional Services Practice: {{advisory_practice_unit}}
  • Execution Runtime & Framework: {{runtime_environment}}
  • OOM Crash Dump Summary: {{oom_crash_dump_summary}}
  • Target Ingestion Throughput: {{target_throughput_tps}}
  • Worker Concurrency Limit: {{worker_concurrency_limit}}
  • Container Memory Ceiling: {{memory_ceiling_mb}}

Task

Design an end-to-end debugging and runtime heap profiling script for {{runtime_environment}} that isolates memory leaks during massive document parsing runs in {{advisory_practice_unit}}, triggers automated heap snapshots before {{memory_ceiling_mb}} exhaustion, and enforces graceful worker recycling.

Method

  1. Analyze {{oom_crash_dump_summary}} to identify uncollected retained objects, closure leaks, and buffer allocation bottlenecks.
  2. Construct an active runtime memory observer that tracks RSS, heapUsed, and external buffer allocations on a 250ms cadence.
  3. Integrate trigger logic to generate V8/Python heap profiles automatically when memory consumption hits 85% of {{memory_ceiling_mb}}.
  4. Build an asynchronous stream pipeline interceptor that enforces backpressure whenever {{target_throughput_tps}} overwhelms parser GC cycles.
  5. Implement a supervisor worker management script that gracefully drains in-flight client document chunks before cycling saturated worker processes.
  6. Generate a heap diff analysis routine to pinpoint lingering object retainers across consecutive document conversion batches.
  7. Provide automated load-generation commands to simulate peak concurrency up to {{worker_concurrency_limit}}.

Constraints

  • Profiling hooks MUST NOT add more than 3% CPU overhead during normal steady-state document parsing.
  • The supervisor script MUST ensure zero document chunk drops during graceful worker recycling.
  • Do not use non-standard native compilation dependencies unless pre-bundled in {{runtime_environment}}.
  • Snapshots and logs MUST NOT write unencrypted client document text to shared disk partitions.

Output format

  1. Leak Diagnostic Assessment: Concise breakdown of the retention tree causing memory bloat.
  2. Production Profiler Script (heap_monitor.js or heap_monitor.py): Full script with event emitters, threshold listeners, and snapshot dumps.
  3. Cluster Supervisor Configuration (cluster_manager.js or supervisor.py): Zero-downtime worker lifecycle script.
  4. Post-Mortem Verification Guide: 4-step checklist to validate memory stability under load.

Self-review

  • Is backpressure correctly handled during document buffer transformation?
  • Does the worker recycle routine drain in-flight promises/tasks before terminating the process?
  • Are memory snapshots securely written to restricted temporary paths?
AuraScore breakdown
79/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 engineering10/12 · Adequate

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-debugging
professional-services
memory-profiling
nodejs
performance