On Wed, 11 Jun 2025 14:16:19 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

> > > > If there is no performance penalty for accessing data from a memory 
> > > > segment created using the global arena, then we could switch to that 
> > > > for JavaFX as well.
> > > 
> > > 
> > > Using memory from the Global arena can actually be _faster_ as we do not 
> > > have to perform any liveness checks for such segments. So, I think this 
> > > is a good move. Also, the memory does not have to be acquired/released if 
> > > the address is conveyed to native code (as the segment's scope never 
> > > closes).
> > 
> > 
> > In this case, you'll need to change 
> > [`free()`](https://github.com/kevinrushforth/jfx/blob/2dd7a35d2eec16b04de1f4cb7aeba31be5d98a55/modules/javafx.graphics/src/main/java/com/sun/marlin/OffHeapArray.java#L126)
> >  to remove the closure of the arena, but I think that then you'll have to 
> > manually clear the memory segments it allocates. This requires non-trivial 
> > modifications with `MarlinUtils`'s cleaner. When @bourgesl and I discussed 
> > these changes, we were unsure what the correct arena for this situation is.
> 
> The alpha map objects are never freed. They are static arrays that are 
> created and filled once, in the static initializer of the 
> `MaskMarlinAlphaConsumer` class. The change I am thinking to propose is 
> [here](https://github.com/kevinrushforth/jfx/commit/6c38c6040d1abd9b84f3648f892215573a8b1275)
>  if you want to take a look before I push it to this PR branch.
> 
> I could still integrate this PR "as is" and file a follow-on for using the 
> global arena for the alpha map arrays depending on what @nlisker and 
> @bourgesl think.

Ah, you're using **2** arenas for the different allocations. That's something I 
didn't think of and seems like a decent solution.

I'm fine with any solution that keeps the rendering correct (obviously) and 
addresses the concerns of memory deallocation, which as I said, can be tricky 
to do.

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

PR Comment: https://git.openjdk.org/jfx/pull/1814#issuecomment-2963086118

Reply via email to