On Thu, 16 Oct 2025 17:37:20 GMT, Sergey Bylokhov <[email protected]> wrote:

>> color is initially returned as 4 element array but we over-write with 3 
>> element and so next time through the loop it is used by but is too short.
>> More details in JBS.
>
> src/java.desktop/share/classes/java/awt/image/ColorConvertOp.java line 811:
> 
>> 809:                 for (int x = 0; x < w; x++) {
>> 810:                     pixel = srcRas.getDataElements(x, y, pixel);
>> 811:                     color = srcCM.getNormalizedComponents(pixel, null, 
>> 0);
> 
> Since this is executed for each pixel, it will generate garbage equal to the 
> image size. Maybe we can cleanly split the usage of the two vars here? Note 
> that the bug only occurs when the source image does not use an ICC profile, 
> but this change would increase garbage for both ICC and non-ICC profiles.

You mean keep the original returned float[] color separate from the one that's 
later over-written.
I'd thought about that but I don't think it is worth it.
It can also be over-written at line 835. There's just too much state tracking 
needed to save
the GC a tiny bit of effort freeing small transient objects.
Also it already is re-initialised for each scanline. See line 807, so it isn't 
(quite) the same array for the entire image anyway.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27785#discussion_r2456806807

Reply via email to