Skip to content
Astera Technology

Check retained buffers after repeated task cycles

Measure explicit retained allocations after temporary work ends.

Download complete case notes and answer keys ↓

Set the decision and its input

The bounded local task allocates a two-byte Buffer per cycle. Fifty faulty cycles retain every buffer in a list, leaving100 bytes against a supplied50-byte allowance. The repair keeps no persistent buffer references, so explicitly retained bytes are0.

Filled local test worksheet
CaseInput JSON
Base test{"cycles":50,"bytesPerCycle":2,"allowedBytes":50}
Download editable CSV ↓

Run the supplied comparison

Actual Buffers are allocated and retained reference lengths measured. This is a controlled retention test, not an operating-system memory reading, garbage-collection guarantee or measurement of the entire process heap.

Faulty and required outputs
PathOutput JSON
Faulty path{"cycles":50,"retainedBytes":100,"withinAllowance":false}
Required path{"cycles":50,"retainedBytes":0,"withinAllowance":true}
Download editable CSV ↓
Complete local Node24.14.1 programme
import assert from 'node:assert/strict';
const smallWhole=(x,max)=>Number.isSafeInteger(x)&&x>=0&&x<=max;

const run=function run(i,corrected=true){
    if(!smallWhole(i.allowedBytes,10000)||!smallWhole(i.cycles,100)||!smallWhole(i.bytesPerCycle,100))return {held:true};const retained=[];
    for(let n=0;n<i.cycles;n++){const buffer=Buffer.alloc(i.bytesPerCycle);if(!corrected)retained.push(buffer);}
    const retainedBytes=retained.reduce((s,b)=>s+b.byteLength,0);return {cycles:i.cycles,retainedBytes,withinAllowance:retainedBytes<=i.allowedBytes};
  };
const cases=[{"input":{"cycles":50,"bytesPerCycle":2,"allowedBytes":50},"corrected":false,"expected":{"cycles":50,"retainedBytes":100,"withinAllowance":false}},{"input":{"cycles":50,"bytesPerCycle":2,"allowedBytes":50},"corrected":true,"expected":{"cycles":50,"retainedBytes":0,"withinAllowance":true}},{"input":{"cycles":0,"bytesPerCycle":2,"allowedBytes":0},"corrected":true,"expected":{"cycles":0,"retainedBytes":0,"withinAllowance":true}},{"input":{"cycles":50,"bytesPerCycle":2,"allowedBytes":null},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Download runnable example ↓

Choose from the boundary evidence

Zero cycles retain zero within a zero allowance. Missing allowance is held, not filled by the observed size.

  1. Define the retained-object measure
  2. Run repeated task cycles
  3. Inspect retained references afterward

Do not present retained Buffer bytes as total system memory.

Editable boundary inputs and outputs
ConditionInput JSONExpected output JSON
no cycles{"cycles":0,"bytesPerCycle":2,"allowedBytes":0}{"cycles":0,"retainedBytes":0,"withinAllowance":true}
allowance not supplied{"cycles":50,"bytesPerCycle":2,"allowedBytes":null}{"held":true}
Download editable CSV ↓

What does the repaired base prove about retention?

Show the worked answer

After fifty cycles the programme retains no buffers in its persistent list. This satisfies that explicit allowance but makes no whole-process memory promise.

Related resources