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

JTable got larger in 1.5.0

XMLWordPrintable

    • 5.0
    • b74
    • generic
    • generic

      According to the test case below and -verbose:gc, a simple empty JTable grew significantly over the course of JDK 1.5. The data below were generated by allocating the indicated number of tables, performing a volley of GCs, and recording the amount of used heap space.

      1.4.2:
      0: 314K
      10: 362K (4.8K/per)
      100: 800K (4.8K/per)
      1000: 5149K (4.8K/per)

      1.5.0:
      0: 413K
      10: 515K (10.0K/per)
      100: 1418K (10.1K/per)
      1000: 10436K (10.0K/per)

      1.6.0b57:
      0: 416K
      10: 518K (10.2K/per)
      100: 1425K (10.1K/per)
      1000: 10477K (10.1K/per

      (FWIW, the 0 number was generated by first allocating 1 table, GCing, then allocating 0 tables and GCing, ensuring that all necessary classes and infrastructure were already loaded).

      As you can see, JTable pretty much doubled in size between 1.4.2 and 1.5, though 1.6 appears to have stayed the course.

      Test case:
      ---
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class GCTest {
          private JTextField allocTextField;
          private JTable[] data;

          public static void main(String[] args) {
              new GCTest();
          }

          public GCTest() {
              JFrame frame = new JFrame("GC Test");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              allocTextField = new JTextField(10);
              allocTextField.setText("0");
              allocTextField.addActionListener(new ActionListener() {
                      public void actionPerformed(ActionEvent e) {
                          int size = Integer.parseInt(allocTextField.getText());
                          System.err.println("allocating: " + size + " tables");
                          data = new JTable[size];
                          for (int i = 0; i < size; i++) {
                              data[i] = new JTable();
                          }
                      }
                  });
              allocTextField.select(0, 1);
              JButton button = new JButton("GC");
              button.addActionListener(new ActionListener() {
                      public void actionPerformed(ActionEvent e) {
                          System.gc();
                          System.runFinalization();
                          System.gc();
                      }
                  });

              frame.getContentPane().setLayout(new GridBagLayout());
              frame.getContentPane().add(allocTextField, new GridBagConstraints(
                            0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
                            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0),
                            0, 0));
              frame.getContentPane().add(button, new GridBagConstraints(
                            1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER,
                            GridBagConstraints.NONE, new Insets(5, 5, 0, 5),
                            0, 0));

              frame.pack();
              frame.show();
              allocTextField.requestFocus();
          }
      }

            bchristi Brent Christian
            bchristi Brent Christian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: