Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8215756

Memory leaks in the AWT on macOS

    Details

    • Subcomponent:
    • Resolved In Build:
      b03
    • CPU:
      generic
    • OS:
      os_x

      Backports

        Description

        While working on some other bug, i found a few memory leaks which may cause the application crash because of not enough of memory:

        Test to reproduce, you need to wait hour or so, depends from the system:

        import java.awt.Color;
        import java.awt.Frame;
        import java.awt.Point;
        import java.awt.Robot;
        import java.util.List;

        /**
         * @test
         * @key headful
         * @bug 8215105
         * @summary tests that Robot can capture the common colors without
         * artifacts
         */
        public final class CheckCommonColors {

            private static final Frame frame = new Frame();
            private static Robot robot;

            public static void main(final String[] args) throws Exception {
                robot = new Robot();
                try {
                    test();
                } finally {
                    frame.dispose();
                }
            }

            private static void test() {
                frame.setSize(400, 400);
                frame.setLocationRelativeTo(null);
                frame.setUndecorated(true);
                while (true)
                    for (final Color color : List.of(Color.WHITE, Color.LIGHT_GRAY,
                                                     Color.GRAY, Color.DARK_GRAY,
                                                     Color.BLACK, Color.RED, Color.PINK,
                                                     Color.ORANGE, Color.YELLOW,
                                                     Color.GREEN, Color.MAGENTA,
                                                     Color.CYAN, Color.BLUE)) {
                        frame.dispose();
                        frame.setBackground(color);
                        frame.setVisible(true);
                        checkPixels(color);
                    }
            }

            private static void checkPixels(final Color color) {
                int attempt = 0;
                Point p = frame.getLocationOnScreen();
                Color pixel = robot.getPixelColor(p.x + frame.getWidth() / 2,
                                                  p.y + frame.getHeight() / 2);
                if (color.equals(pixel)) {
                    return;
                }
            }
        }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  serb Sergey Bylokhov
                  Reporter:
                  serb Sergey Bylokhov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: