Skip to content

GraalJS memory leak in Engine #121

Open
@mdsina

Description

@mdsina

Hello.
I'm creating service like FaaS for JS scripts with limited API and found memory leak issues on prototyping different approaches while using Graal Polyglot.

Approaches that I've trying to implement:

  1. Pool of Context with single Engine. Source evaluated once in Context. Any JS code wrapped to unique namespace, that can be accessible as member of Context and executed.
    Any other invocations just execute existing member and nothing more
  2. Single Engine, Sources are cached. On any new invocation we just getting existing Source and evaluate them in new Context that created for every invocation.
    After that getting function member from Context and execute (as in previous approach)
  3. New Engine and New Context for every invocation, Sources are built once.

Only third approach have no memory leaks, because GC will grab them out from heap.
In first and second approaches are memory leaks. Looks like Engine have issues on executing some code and generates much data for each invocation, that will be never removed from Engine.

I have a prototype that reproduces the first approach:
https://github.com/mdsina/graaljs-executor-web-service

Also I wrote a load tests that simulate real-world invocations of JS code:
https://github.com/mdsina/graaljs-executor-web-service-load-tests/tree/master
Service was executed with VM options:

-Xmx2g -XX:+UseG1GC

default

Looks like links to ContextJS never be removed.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingmemoryMemory footprint, memory leaks

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions