On Mon, 20 Nov 2023 10:04:42 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

>> Each time `CUPSPrinter.initMedia()` method is called it creates new 
>> `CustomMediaSizeName` objects which are all collected in static 
>> `CustomMediaSizeName.customEnumTable` field. A lot of created duplicated 
>> `CustomMediaSizeName` objects wastes java heap space and can lead to 
>> `PrintService.getAttributes()` method call time degradation especially when 
>> a lot of different printers are installed in the operation system.
>> The same is true for `CustomMediaTray` class.
>> 
>> The fix adds a `create()` method and a hash map which allows to reuse 
>> created  `CustomMediaSizeName/CustomMediaTray` objects. It seems that adding 
>> `equals(...)` method to `CustomMediaSizeName/CustomMediaTray` classes 
>> violates parent `Media` class contract which compares media objects only by 
>> `value` fields. The fix adds inner classes which are used as a key in 
>> corresponding hash maps.
>> 
>> `test/jdk/javax/print` and `test/jdk/java/awt/print` automated tests were 
>> run to check the fix on Linux and macOS.
>
> test/jdk/javax/print/CustomMediaSizeNameOOMETest.java line 37:
> 
>> 35: 
>> 36: public class CustomMediaSizeNameOOMETest {
>> 37: 
> 
> Seems testcase is passing for me even without the fix in windows

Yes, this is true. I am not able to reproduce the issue on Windows. It seems 
that it can be specific to Linux and macOS.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16167#discussion_r1401635690

Reply via email to