Bug in the Table? Memory leak in editable mode.

Hi,
I have probably found a bug in the Table component. If the table is in editable mode and you scroll or select an row, the table eats more and more memory. You can simulate it in this example:

public class TableExample extends VerticalLayout {
  private Table table = new Table("ISO-3166 Country Codes and flags");
  private Label sizeLabel = new Label();

  public TableExample() {
    addComponent(table);
    table.setEditable(true);
    table.setWidth("100%");
    table.setHeight("170px");
    table.setSelectable(true);
    table.setContainerDataSource(ExampleUtil.getISO3166Container());
    table.setColumnHeaders(new String[] { "Country", "Code", "Icon file" });
    table.setColumnAlignment(ExampleUtil.iso3166_PROPERTY_SHORT, Table.ALIGN_CENTER);
    table.setColumnExpandRatio(ExampleUtil.iso3166_PROPERTY_NAME, 1);
    table.setColumnWidth(ExampleUtil.iso3166_PROPERTY_SHORT, 70);

    addComponent(sizeLabel);

    addComponent(new Button("Show size of the table", new ClickListener() {
      public void buttonClick(ClickEvent event) {
        table.requestRepaintAll();
        sizeLabel.setValue("Size of the table: " + DebugUtils.getSize(table) + " bytes");
      }
    }));

    addComponent(new Button("Select the second row", new ClickListener() {
      public void buttonClick(ClickEvent event) {
        table.select("AL");
        sizeLabel.setValue("Size of the table: " + DebugUtils.getSize(table) + " bytes");
      }
    }));
  }
}


class DebugUtils {
  public static class ByteCountNullOutputStream extends OutputStream implements Serializable {
    private static final long serialVersionUID = 4220043426041762877L;
    private long bytes;
    @Override
    public void write(int b) { bytes++; }
    public long getBytes() { return bytes; }
  }

  public static long getSize(Object object) {
    ByteCountNullOutputStream os = new ByteCountNullOutputStream();
    ObjectOutputStream oos;
    try {
      oos = new ObjectOutputStream(os);
      oos.writeObject(object);
    } catch (IOException e) {
      e.printStackTrace();
    }
    return os.getBytes();
  }
}

The size of the table is growing quite quickly. What to do with this?
Thank you for reply
Petr

This seems to indeed be a problem in Table when using it in edit mode. The components created by the TableFieldFactory are correctly detached but still connected to their data source (through the container in the Table) and will thus not be garbage collected. Created
#6071
for this issue.