Skip to content

Commit

Permalink
Alternative solution to clear mem.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw committed Jan 9, 2025
1 parent 557ac0c commit 624282e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 16 deletions.
1 change: 0 additions & 1 deletion assembly/api-generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export function runVm(input: VmInput, logs: boolean = false): VmOutput {

// release used pages back
int.memory.free();
builder.destroy();

return output;
}
Expand Down
4 changes: 2 additions & 2 deletions assembly/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
9 changes: 0 additions & 9 deletions assembly/memory-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
4 changes: 0 additions & 4 deletions assembly/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 624282e

Please sign in to comment.