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

Are objects being created in the global scope everytime V8JavaObjectUtils#translateJavaArgumentToJavascript is called? #20

Open
newk5 opened this issue Jul 8, 2018 · 0 comments

Comments

@newk5
Copy link

newk5 commented Jul 8, 2018

I was looking at the source and it seems to me that the method to translate a java object to a javascript V8Value is creating a new global object on the global scope of the V8 runtime with a random UUID. Is my understanding correct about this?

If this is the case, I have to say this worries me a bit. I noticed there is a cache in place that checks if the object already exists to avoid creating it again, but in my use case that will be a very rare scenario. My application is a long running server that will be up for months without restarting, it will be receiving events quite frequently. Java methods with several arguments are triggered when these events happen, I'm then using the translateJavaArgumentToJavascript method to convert those arguments to javascript V8Values
and calling javascript functions using v8.executeJSFunction and passing those arguments to those javascript functions. That said, I only want those objects that I'm passing as arguments to exist inside that javascript function scope and not in the global scope, because if not, after a few months running my application, I will have a few hundred maybe thousand global objects on the global scope, and I'm concerned this is just not very memory effecient.

Is there a better way to handle this? Do java objects absolutely have to be injected into the global scope to convert them to V8 values?

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

1 participant