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.
| Case | Input JSON |
|---|---|
| Base test | {"cycles":50,"bytesPerCycle":2,"allowedBytes":50} |
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.
| Path | Output JSON |
|---|---|
| Faulty path | {"cycles":50,"retainedBytes":100,"withinAllowance":false} |
| Required path | {"cycles":50,"retainedBytes":0,"withinAllowance":true} |
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);}
Choose from the boundary evidence
Zero cycles retain zero within a zero allowance. Missing allowance is held, not filled by the observed size.
- Define the retained-object measure
- Run repeated task cycles
- Inspect retained references afterward
Do not present retained Buffer bytes as total system memory.
| Condition | Input JSON | Expected 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} |
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.