Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about 'loadWithNewGlobal' and childRealm heap memory issue #607

Closed
tellmewhattodo opened this issue May 23, 2022 · 3 comments
Closed

about 'loadWithNewGlobal' and childRealm heap memory issue #607

tellmewhattodo opened this issue May 23, 2022 · 3 comments

Comments

@tellmewhattodo
Copy link

tellmewhattodo commented May 23, 2022

I use GraalJS with 'load' enabled (use Context in Java, not Node mode), and use loadWithNewGlobal to run some script (cause it provides new global);

I found that there might be heap issue about this.
I checked heap histogram, and found there is a lot of [com.oracle.truffle.js.runtime.builtins.JSFunctionObject$Unbound]
stayed after full gc.

according to source code
[com.oracle.truffle.js.builtins.GlobalBuiltins.JSGlobalLoadWithNewGlobalNode:1441]
There is a new childRealm created via [com.oracle.truffle.js.runtime.JSRealm#createChildRealm], and not cleared from it's parent's [com.oracle.truffle.js.runtime.JSRealm#innerContextsToClose] when loadWithNewGlobal finished.

The only way to clear all the [com.oracle.truffle.js.runtime.JSRealm#innerContextsToClose]
is to close the whole Context, which I'd like not to do , it's rather expansive.

it is suspected to be a memory leak issue, look forward about a way round or fix.

issue found in GraalVM 21.3.2 JDK11

@woess
Copy link
Member

woess commented May 24, 2022

It would be great if you could try with 22.1.0+. The code has since been changed (there's no innerContextsToClose list anymore), so this might've already been fixed.

@tellmewhattodo
Copy link
Author

It would be great if you could try with 22.1.0+. The code has since been changed (there's no innerContextsToClose list anymore), so this might've already been fixed.

it's confirmed, there's no memory leak on 22.1.0 Graal CE. will there be fix for 21.3?

And I noticed that there won't be 'children context' concept in 22.1.0, will this change make loadWithNewGlobal more quickly? it costs about 1ms in my case, at GraalVM CE 21.3.2.

@woess
Copy link
Member

woess commented Jun 29, 2022

will there be fix for 21.3?

Unfortunately, I don't think we are going to backport this change since it's fairly intrusive.

And I noticed that there won't be 'children context' concept in 22.1.0, will this change make loadWithNewGlobal more quickly? it costs about 1ms in my case, at GraalVM CE 21.3.2.

I don't expect any relevant speedup from this, but maybe...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants