Skip to content

Commit ea564b2

Browse files
committed
Count references at 8 bytes and check at least once per cap of allocation
1 parent 9c99968 commit ea564b2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/runtime.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class JArray extends JObject {
183183
constructor(cls: JClass, a: ArrayData) {
184184
super(cls, EMPTY);
185185
this.a = a;
186-
if (allocationCheck?.enabled) allocated(ArrayBuffer.isView(a) ? a.byteLength : a.length * 4);
186+
if (allocationCheck?.enabled) allocated(ArrayBuffer.isView(a) ? a.byteLength : a.length * 8);
187187
}
188188
}
189189

@@ -385,7 +385,7 @@ export function setMaxHeap(bytes: number) {
385385
export function hasMaxHeap() { return explicitMaxHeap; }
386386
let allocationCheck: { cap: number; step: number; allocated: number; baseline: number; enabled: boolean; usage: () => number; gc?: () => void } | null = null;
387387
export function setAllocationCheck(cap: number, usage: () => number, gc?: () => void) {
388-
allocationCheck = { cap, step: Math.max(4 << 20, cap / 16), allocated: 0, baseline: 0, enabled: false, usage, gc };
388+
allocationCheck = { cap, step: Math.min(cap, Math.max(4 << 20, cap / 16)), allocated: 0, baseline: 0, enabled: false, usage, gc };
389389
}
390390
export function clearAllocationCheck() { allocationCheck = null; }
391391
export function resetAllocationCheck() {

0 commit comments

Comments
 (0)