RFR: 8259046: ViewPainter.ROOT_PATHS holds reference to Scene causing memory leak

Kevin Rushforth kcr at openjdk.java.net
Wed Jan 27 13:35:49 UTC 2021

Prism implements a dirty region optimization, where in many cases, only part of the scene graph is re-rendered when something changes. In support of this, the `ViewPainter` class in the Quantum Toolkit keeps an array of node paths, `ROOT_PATHS`, which is a list of sub-trees in the scene graph that need to be rendered based on a change to that node. The entries in the `ROOT_PATHS` array are intended to be transient during the rendering of a single pass of a single scene. They are recreated every time a scene is rendered. The leak occurs because the entries are not cleared after being used. The fix is to clear each entry after it is rendered. In addition to static analysis, which shows that the entries are never used again after a frame is rendered, I have done a full build and test, including manual tests, to be sure that there is no regression.

I have added a test that will fail consistently on Mac and Windows (and intermittently on Linux) without the fix. It passes consistently on all platforms with the fix.

Even though this is a simple change, it is in an area that has historically been fragile, so I would like two reviewers.


Commit messages:
 - 8259046: ViewPainter.ROOT_PATHS holds reference to Scene causing memory leak

Changes: https://git.openjdk.java.net/jfx/pull/388/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jfx&pr=388&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8259046
  Stats: 116 lines in 2 files changed: 116 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jfx/pull/388.diff
  Fetch: git fetch https://git.openjdk.java.net/jfx pull/388/head:pull/388

PR: https://git.openjdk.java.net/jfx/pull/388

More information about the openjfx-dev mailing list