Skip to content

ClosedByInterruptException while computing Path to GC Root in Heap Viewer #662

Closed

Description

@thurka

VisualVM throws java.nio.channels.ClosedByInterruptException while computing the nearest GC root / path to GC root for an instance in the Heap Viewer.

VisualVM 2.2.1, JDK 17.

  java.nio.channels.ClosedByInterruptException
      at java.base/java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:199)
      at java.base/sun.nio.ch.FileChannelImpl.endBlocking(FileChannelImpl.java:171)
      at java.base/sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:293)
      at org.graalvm.visualvm.lib.jfluid.heap.AbstractLongMap$LongMemoryMappedData.force(AbstractLongMap.java:542)
      at org.graalvm.visualvm.lib.jfluid.heap.AbstractLongMap$AbstractData.writeToStream(AbstractLongMap.java:265)
      at org.graalvm.visualvm.lib.jfluid.heap.AbstractLongMap.writeToStream(AbstractLongMap.java:175)
      at org.graalvm.visualvm.lib.jfluid.heap.LongMap.writeToStream(LongMap.java:310)
      at org.graalvm.visualvm.lib.jfluid.heap.HprofHeap.writeToStream(HprofHeap.java:361)
      at org.graalvm.visualvm.lib.jfluid.heap.HprofHeap.writeToFile(HprofHeap.java:335)
      at org.graalvm.visualvm.lib.jfluid.heap.NearestGCRoot.computeGCRoots(NearestGCRoot.java:128)
      at org.graalvm.visualvm.lib.jfluid.heap.NearestGCRoot.getNearestGCRootPointer(NearestGCRoot.java:87)
      at org.graalvm.visualvm.lib.jfluid.heap.HprofHeap.getNearestGCRootPointer(HprofHeap.java:862)
      at org.graalvm.visualvm.lib.jfluid.heap.InstanceDump.getNearestGCRootPointer(InstanceDump.java:87)
      at org.graalvm.visualvm.heapviewer.java.impl.PathToGCRootPlugin.computeInstanceRoots(PathToGCRootPlugin.java:366)
      at org.graalvm.visualvm.heapviewer.java.impl.PathToGCRootPlugin$1.computeData(PathToGCRootPlugin.java:193)
      at org.graalvm.visualvm.heapviewer.ui.TreeTableView$1.lazilyComputeChildren(TreeTableView.java:147)
      at org.graalvm.visualvm.heapviewer.model.HeapViewerNode$1.doInBackground(HeapViewerNode.java:179)
      at javax.swing.SwingWorker$1.call(SwingWorker.java:304)
      at java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at javax.swing.SwingWorker.run(SwingWorker.java:343)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
      at java.lang.Thread.run(Thread.java:842)

Activity

  1. self-assigned this
    on Jun 17, 2026
  2. thurka commented on Jun 17, 2026

    @thurka
    MemberAuthor

    HeapOperations.initializeGCRoots() uses the first heap instance as a dummy trigger for GC-root computation. If that first instance is itself a GC root, NearestGCRoot.getNearestGCRootPointer() returns immediately and does not compute GC-root paths for the heap. HeapOperations still marks GC roots as initialized.

    Later, the real GC-root computation is triggered from the GC Root view’s lazy SwingWorker. If that worker is interrupted while cache data is being persisted, FileChannel.write() can throw ClosedByInterruptException.

    Steps To Reproduce

    1. Open a large heap dump.
    2. Run on Linux, macOS Apple Silicon
    3. Use a heap dump where the first instance returned by heap.getAllInstancesIterator().next() is a GC root.
    4. Open the GC Root view for a non-root object or class.
    5. While GC-root computation is still running, interrupt the view computation by changing selection, reloading the view, sorting/filtering, closing the view, or otherwise resetting the tree.
    6. ClosedByInterruptException will be thrown from AbstractLongMap$LongMemoryMappedData.force() during cache persistence.
  3. added a commit that references this issue on Jun 19, 2026
  4. thurka commented on Jun 20, 2026

    @thurka
    MemberAuthor

    FIxed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions