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

Java AWT on win95: Resource exhaustion by heavyweight components

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.1.4, 1.1.6, 1.1.7, 1.1.8
    • Fix Version/s: 1.3.0
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      kestrel
    • CPU:
      generic, x86
    • OS:
      windows_95, windows_nt

      Description

      There is a resource exhaustion problem which is specific to Windows '95
      and Windows '98 - it does not affect NT 4.0

      It is present in all Sun JDK versions including JDK 1.1.6, and JDK 1.2 Beta
      releases.

      It is related to the crash of bug 4040282 which has been fixed, but the resource
      exhaustion problem still exists.

      Every "window" you create on a Windows '95 system, consumes user/system
      resources from a very limited global heap.
      Somewhere between 1,000-1,200 windows appears to be the absolute limit.

      These do not have to be top-level windows, but the Microsoft win32 APIs typically create controls as Windows.
      A similarly architected application written directly in C++ using MFC would
      probably encounter the same problem.

      The Sun win32 AWT implementation creates every concrete AWT UI component in
      a separate "window", and so is afflicted.

      Here is a test program. Note the component type is irrelevant.

      /**
       * Sample class which allocates 40 windows containing
       * each 50 labels in a 5 by 10 grid. A total of 2000
       * text labels are created.
       *
       * This test will fail on Win95 using JDK1.1.6 when
       * 1,000-1,200 labels are created, due to lack of system
       * or user resources. You can use the Resource Meter
       * utillity to observer the percentage of free resources.
       * This tool can be found in the Start menu under
       * Programs/Accessories/System Tools.
       *
       */

      import java.awt.*;

      class gtest {
          public static void main(String argv[]) {
              Toolkit tk = Toolkit.getDefaultToolkit();

              int count = 0;
              try {
                  for (int i = 0 ; i < 40 ; i++) {
                      Frame f = new Frame(String.valueOf(i));
                      f.reshape(10 + i*4, 10 + i*10, 400, 300);
                      f.setLayout(new GridLayout(10, 5));

                      for (int j = 0 ; j < 50 ; j++) {
                          Component c = new Label(i + "," + j);
                          f.add(c);
                          count++;
                      }
                      f.show();
                      System.out.println("count=" + count);
                  }
              } finally {
                  System.out.println("final count=" + count);
              }
          }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rkhansunw Robi Khan (Inactive)
              Reporter:
              prr Philip Race
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: