RFR: 8349105: Pagination: exception initializing in a background thread [v4]

Kevin Rushforth kcr at openjdk.org
Mon Feb 10 22:38:16 UTC 2025


On Mon, 10 Feb 2025 22:30:32 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> ## Root Cause
>> Animation gets started in a background thread, which causes the animation handler to run in the FX application thread, thus creating simultaneous access to the control's fields (list of children in this case).
>> 
>> ## Solution
>> Postpone the animation unless running in the FX application thread.  There is no functional difference if the component is created/used in the FX application thread.
>
> Andy Goryachev has updated the pull request incrementally with one additional commit since the last revision:
> 
>   slow down gc

I filed [JDK-8349756](https://bugs.openjdk.org/browse/JDK-8349756) to track the leak. I think the call to `System.gc()` is effective only because it slows down the tight loop.

tests/system/src/test/java/test/robot/javafx/scene/NodeInitializationStressTest.java line 417:

> 415:             if (nextBoolean(0.1)) {
> 416:                 System.gc();
> 417:             }

While investigation the Pagination leak I also took a closer look at this `System.gc()`. The reason this prevents the OOM has nothing to do with the GC per se, but rather it slows the loops down so much that they don't generate nearly as much garbage in the 5 seconds the test runs in. You can verify that yourself by replacing the `System.gc()` with `sleep(10)` or similar (depending on the speed of your system), and get the same effect.

I don't think there is a good reason to call `System.gc()` at all in this loop. Once the leak is fixed, it  should run fine at full speed.

-------------

PR Review: https://git.openjdk.org/jfx/pull/1698#pullrequestreview-2607335526
PR Review Comment: https://git.openjdk.org/jfx/pull/1698#discussion_r1949997384


More information about the openjfx-dev mailing list