RFR: 8259046: ViewPainter.ROOT_PATHS holds reference to Scene causing memory leak
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.
- 8259046: ViewPainter.ROOT_PATHS holds reference to Scene causing memory leak
Stats: 116 lines in 2 files changed: 116 ins; 0 del; 0 mod
Fetch: git fetch https://git.openjdk.java.net/jfx pull/388/head:pull/388
More information about the openjfx-dev