有没有办法找出特定的多语言上下文使用了多少内存?
我想用不同的脚本运行多个上下文,但我想看看每个脚本使用了多少内存。(就我而言,即使是估计也足够了)
public static void main(String[] args) {
// dumb example to see the memory go up
Context polyglot = Context.newBuilder().build();
polyglot.eval("js", "let x = []; for (let i = 0; ; ++i) x.push('data-' + i)");
// pseudo code to check memory
new Thread(() -> { while (true) { print(getMemoryUsed(polyglot)); } }).start();
}