-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
7001133: OutOfMemoryError by CustomMediaSizeName implementation #16167
7001133: OutOfMemoryError by CustomMediaSizeName implementation #16167
Conversation
👋 Welcome back alexsch! A progress list of the required criteria for merging this PR into |
@AlexanderScherbatiy The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
@AlexanderScherbatiy This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
TLDR; I suspect your problem can be solved with a one line check for null, but there's still value in more changes. The long story I looked into it and it starts with the following which goes all the way back to JDK 1.5 } This means EVERY call to IPPPrintService.getAttributes() re-initialises all attributes. I can see this being important for some service attributes, like whether the printer is up and running,
That's why you are seeing so many calls to initMedia() if we want to do fine-grained checking for whether the default media has changed, we could do that but But that is not a complete solution, even if you never hit this case where if it is not a cups printer, we go to IPP, that's going to do the same re-creation of all the custom media so your map still helps there, even if the null check is added. But I'm not sure why we are redoing that work either, so it goes back to the "init=false" being over-kill I think we need to stop setting init=false and get just what we need. Like we need a "re-init" that handles this. Right now, I'm inclined to suggest you push the fix you have (modulo my existing comments that need to be addressed) |
I submitted https://bugs.openjdk.org/browse/JDK-8320365 and I'll take care of it. Perhaps for 22 but time is getting short there. |
import javax.print.PrintServiceLookup; | ||
|
||
public class CustomMediaSizeNameOOMETest { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems testcase is passing for me even without the fix in windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@AlexanderScherbatiy This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 794 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
What should be done with this pull request as the #16752 |
I thought your fix is still useful, even if the problem isn't visible any more. |
/integrate |
Going to push as commit 10335f6.
Your commit was automatically rebased without conflicts. |
@AlexanderScherbatiy Pushed as commit 10335f6. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Each time
CUPSPrinter.initMedia()
method is called it creates newCustomMediaSizeName
objects which are all collected in staticCustomMediaSizeName.customEnumTable
field. A lot of created duplicatedCustomMediaSizeName
objects wastes java heap space and can lead toPrintService.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 createdCustomMediaSizeName/CustomMediaTray
objects. It seems that addingequals(...)
method toCustomMediaSizeName/CustomMediaTray
classes violates parentMedia
class contract which compares media objects only byvalue
fields. The fix adds inner classes which are used as a key in corresponding hash maps.test/jdk/javax/print
andtest/jdk/java/awt/print
automated tests were run to check the fix on Linux and macOS.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16167/head:pull/16167
$ git checkout pull/16167
Update a local copy of the PR:
$ git checkout pull/16167
$ git pull https://git.openjdk.org/jdk.git pull/16167/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16167
View PR using the GUI difftool:
$ git pr show -t 16167
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16167.diff
Webrev
Link to Webrev Comment