0

I'm running several instances of titandb / gremlin-server.sh but it keeps running out of memory under high load. How and where do I set the property mentioned in th the docs?

I would like to set #jsr223.groovy.engine.keep.globals to phantom.

Thanks

Cache Management

If Gremlin Server processes a large number of unique scripts, the cache will grow beyond the memory available to Gremlin Server and an OutOfMemoryError will loom. Script parameterization goes a long way to solving this problem and running out of memory should not be an issue for those cases. If it is a problem or if there is no script parameterization due to a given use case (perhaps using with use of sessions), it is possible to better control the nature of the script cache from the client side, by issuing scripts with a parameter to help define how the garbage collector should treat the references.

The parameter is called #jsr223.groovy.engine.keep.globals and has four options:

hard - available in the cache for the life of the JVM (default when not specified).

soft - retained until memory is "low" and should be reclaimed before an OutOfMemoryError is thrown.

weak - garbage collected even when memory is abundant.

phantom - removed immediately after being evaluated by the ScriptEngine.

By specifying an option other than hard, an OutOfMemoryError in Gremlin Server should be avoided. Of course, this approach will come with the downside that compiled scripts could be garbage collected and thus removed from the cache, forcing Gremlin Server to recompile later.

Scott
  • 21
  • 2

1 Answers1

0

It is a per request feature:

it is possible to better control the nature of the script cache from the client side, by issuing scripts with a parameter to help define how the garbage collector should treat the references.

You must construct your request with a parameter called #jsr223.groovy.engine.keep.globals and it should have a value of phantom in your case.

For REST I think you would do:

curl -X POST -d "{\"gremlin\":\"100-x\", \"bindings\":{\"x\":1, \"#jsr223.groovy.engine.keep.globals\":\"phantom\"}}" "http://localhost:8182"
stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Thanks stephen. I just need to work out how to pass this using gremlin-php and sockets now. – Scott Oct 24 '15 at 15:28