-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Given that a VirtualMachine
could potentially take up a lot of memory, what would be the smartest way to make a JS class to manage it? The pyEval
function is sufficient for simple things, but it might be desirable to persist the context over, e.g. for a REPL.
I see two or three ways to do this:
- Hold created
VirtualMachines
in a global HashMap by randomly generated IDs, and have a.destroy()
method on the JS class that has to be called or risk a memory leak. - Only allow one
VirtualMachine
per JS context, held in a global variable, initialized at load. - Implement a way for the entire Python context to be serialized (probably not feasible at the moment, nor necessarily worth the time).
I considered some stuff with maybe JS WeakSet
s or WeakMap
s (that take an object as a key but don't prevent it or its value from being garbage-collected), but I don't think that would be able to do anything.
Metadata
Metadata
Assignees
Labels
No labels