Package org.graalvm.tools.insight.heap


package org.graalvm.tools.insight.heap
Support for generating .hprof files in Java Profiler Heap Dump Format and a TruffleInstrument to capture heap dumps from Truffle languages.

Embedding into Java Applications

When embedding GraalVM dynamic languages in Java applications via Context one can enabled not only GraalVM Insight scripts. One can also enable heap object in the Insight scripts and capture the generated heaps in supplied OutputStream use:
Map<String, Instrument> instruments = ctx.getEngine().getInstruments();
Instrument heapInstrument = instruments.get("heap");

@SuppressWarnings("unchecked")
Consumer<OutputStream> consumeOutput = heapInstrument.lookup(Consumer.class);

heapOutput = new ByteArrayOutputStream();
consumeOutput.accept(heapOutput);
Whenever heap.dump(...) is called to perform cooperative heap dumping, the output is sent to the registered OutputStream