diff --git a/assembly/api-generic.ts b/assembly/api-generic.ts index d962040..5c79cda 100644 --- a/assembly/api-generic.ts +++ b/assembly/api-generic.ts @@ -119,7 +119,6 @@ export function runVm(input: VmInput, logs: boolean = false): VmOutput { // release used pages back int.memory.free(); - builder.destroy(); return output; } diff --git a/assembly/api.ts b/assembly/api.ts index c632da0..65abc0e 100644 --- a/assembly/api.ts +++ b/assembly/api.ts @@ -2,13 +2,13 @@ import { InitialChunk, InitialPage, buildMemory } from "./api-generic"; import { Decoder } from "./codec"; import { Gas } from "./gas"; import { Interpreter, Status } from "./interpreter"; -import {MemoryBuilder} from "./memory"; +import { MemoryBuilder } from "./memory"; import { Access, PAGE_SIZE } from "./memory-page"; import { decodeProgram, liftBytes } from "./program"; import { NO_OF_REGISTERS, REG_SIZE_BYTES, Registers } from "./registers"; let interpreter: Interpreter | null = null; -let builder = new MemoryBuilder(); +const builder = new MemoryBuilder(); export function resetGeneric(program: u8[], flatRegisters: u8[], initialGas: Gas): void { const p = decodeProgram(liftBytes(program)); diff --git a/assembly/memory-page.ts b/assembly/memory-page.ts index 4e28496..3c0719e 100644 --- a/assembly/memory-page.ts +++ b/assembly/memory-page.ts @@ -73,13 +73,4 @@ export class Arena { release(page: RawPage): void { this.free.push(page); } - - /** - * Seems like there is an issue with cyclic dependency here that AS GC can't resolve, - * so we have to clear the references manually. - */ - destroy(): void { - this.free = []; - this.extraPageIndex = 0; - } } diff --git a/assembly/memory.ts b/assembly/memory.ts index e3e7efa..896e305 100644 --- a/assembly/memory.ts +++ b/assembly/memory.ts @@ -55,10 +55,6 @@ export class MemoryBuilder { build(sbrkAddress: u32): Memory { return new Memory(this.arena, this.pages, sbrkAddress); } - - destroy(): void { - this.arena.destroy(); - } } export class Memory {