Skip to content

One managed heap across languages

How Elide shares one managed heap and handles garbage collection across Truffle languages.

On this page

Interactive tour: One managed heap across languagesInteractive tour: One managed heap across languages

Learn more

Elide’s JavaScript, TypeScript and Python objects share one managed heap with the engine’s Kotlin and Java objects. One collector follows references across those languages, so objects can cooperate without dividing their managed lifetimes across separate heaps.[1][2]

Choose the collector when you build: Serial GC for low memory overhead in CLI tools, desktop apps and low-traffic servers; G1 GC for high throughput and responsive servers.[3]

Keep memory use low with Serial

Serial GC uses one collector thread and pauses application execution during collection. Young collections copy live objects into survivor space and promote older survivors. Full collections reclaim unused objects across both generations. This simple design keeps memory overhead low, making Serial a strong fit for smaller applications.[3]

Sustain server throughput with G1

G1 divides the heap into regions and performs marking concurrently with application execution. Young collections move live objects during pauses; mixed collections reclaim selected old regions alongside young ones. A pause-time goal guides how much work G1 takes on, balancing responsive requests with sustained throughput.[3][4]

Collect cross-language cycles together

A JavaScript array can reference a Python dictionary holding a JavaScript function. Truffle represents these managed values as host objects, giving the collector one connected object graph to follow.[1][2]

A Python list and a JavaScript closure can also keep each other alive. Once neither remains reachable from the program’s roots, one collector can reclaim the cycle. Serial and G1 both work over this shared graph.[1][3]

GraalPy coordinates native extension objects through its reference-counting bridge and cycle detector, connecting native lifetimes to managed references.[5]

Size and inspect the shared heap

Elide accepts -Xmx and -XX:MaxHeapSize across its Truffle guest languages. These flags set the isolate’s address-space reservation; Substrate VM sizes the managed heap within that reservation using the collector’s memory policy.[6]

Elide includes heap dumps, jvmstat and JFR. VisualVM opens heap dumps to show managed objects, their sizes and the references retaining them across the engine and guest runtimes.[7][8]

Sources

  1. Truffle interoperability — managed value representations and cross-language access.
  2. Polyglot programming — languages exchanging values in one memory space.
  3. Native Image memory management — Serial and G1, build-time collector selection, heap sizing and pause-time goals.
  4. G1 collection — regions, concurrent marking and mixed collections.
  5. GraalPy native extension memory management — reference counting and cycles across native and managed objects.
  6. Elide isolate creation — translating the requested heap size into an isolate address-space reservation.
  7. Elide monitoring configuration — included runtime monitors.
  8. Heap inspection with VisualVM — creating and exploring managed-heap dumps.

Was this page helpful?