hi all,
I assume that issue is related to ImageBundle and to IE6 only (none of
related issues denotes IE version),
GWT use alpha loader filter for ImageBundle implementation which is
not really part of IE rendering but some superficious bad fix to lack
of alpha transparency support, I've read few things about that
recently and could find them,
I've modified example code to remove few things that are not really
related to ImageBundle implementation and possible leaking,
It does not leak in IE7, however that rendering can be slow because IE
creates loader instances for each image, which slows rendering a lot.
Memory use varies around 4mb from peak to bottom. Peak is when images
are fully rendered, bottom when page is cleared or started,
I assume that version on IE6 will behave worst,
Code is only for IE because I've hardcoded image bundle
implementation,
package tests.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.IncrementalCommand;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class TestMemoryLeak implements EntryPoint {
private Button clearTableButton;
private Button addRowsButton;
private Label rowCountLabel;
private FlexTable table;
private static final String FILTER_PROP =
"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='
http://gwt-
issues.floreysoft.com/com.floreysoft.MemoryLeak/
E3E647DA778B4DEF3F3A8E4FDDF52741.cache.png',sizingMethod='crop');";
private static final String DIV_HTML = "<div style=\"{width: 24px;
height: 24px;}\"></div>";
private static Element div;
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
final DockPanel dockPanel = new DockPanel();
rootPanel.add(dockPanel);
final HorizontalPanel buttonPanel = new HorizontalPanel();
dockPanel.add(buttonPanel, DockPanel.NORTH);
addRowsButton = new Button();
buttonPanel.add(addRowsButton);
addRowsButton.addClickListener(new ClickListener() {
// create rows within grid
// fill each grid cell with div with alpha-filter (IE ONLY!!)
used
public void onClick(final Widget sender) {
if (div == null) {
div = DOM.createElement(DIV_HTML);
DOM.setStyleAttribute(div, "filter", FILTER_PROP);
}
blockUI(true);
IncrementalCommand insertRows = new IncrementalCommand() {
int rowCount, i;
/* @Override */
public boolean execute() {
rowCount = table.getRowCount();
if (rowCount < 100) {
for (i = 0; i < 10; i++) {
table.setHTML(rowCount, i, div.toString());
}
rowCountLabel.setText("added #" + (rowCount + 1)
+ " rows already");
return true;
} else {
rowCountLabel.setText(table.getRowCount() + " rows
inserted");
blockUI(false);
return false;
}
}
};
DeferredCommand.addCommand(insertRows);
}
});
addRowsButton.setText("Add 100 rows");
clearTableButton = new Button();
buttonPanel.add(clearTableButton);
clearTableButton.addClickListener(new ClickListener() {
// remove each greed cell and then row
public void onClick(final Widget sender) {
rowCountLabel.setText("removing rows");
blockUI(true);
Timer clearingRowsTask = new Timer() {
int rowCount, i;
/* @Override */
public void run() {
rowCount = table.getRowCount();
if (rowCount > 0) {
for (i = 0; i < 10; i++) {
table.clearCell(rowCount - 1, i);
}
table.removeRow(rowCount - 1);
} else {
cancel();
rowCountLabel.setText("rows removed");
blockUI(false);
}
}
};
clearingRowsTask.scheduleRepeating(10);
}
});
clearTableButton.setText("Clear table");
rowCountLabel = new Label("No rows");
buttonPanel.add(rowCountLabel);
table = new FlexTable();
dockPanel.add(table, DockPanel.CENTER);
}
// just used to block UI to not invoke methods while they execute
private void blockUI(boolean block) {
addRowsButton.setEnabled(!block);
clearTableButton.setEnabled(!block);
}
}
regards,
Peter
On Feb 20, 4:17 pm, "Kelly Norton" <
knor...@google.com> wrote:
> I'll post both versions of the test app this afternoon.
>
> /kel
>
> On Feb 20, 2008 10:12 AM, Joel Webber <
j...@google.com> wrote:
>
>
>
> > Hmm... I assume this is a series of refreshes that delineates the spikes
> > we see in (B). Sure looks like something's escaping collection across runs.
> > Could you try running Drip on the test app to see if there are elements
> > being leaked? Or if you can put up a test server I can do it from my box.
>
> > On 2/19/08, Kelly Norton <
knor...@google.com> wrote:
>
> > > Something is leaking here, but I'm not sure what it is. I added larger
> > > images (188px x 300px) to Daniel's proof-of-concept app and the graph looks
> > > much different. Region A is the graph running with the original small
> > > images. Region B is the same code with a larger image. You can see that the
> > > image instances are being disposed but there is still a growth that seems to
> > > be a function of the number of images (or # of cells in the flex table)
> > > rather than the area. This will probably take some more investigation, but
> > > this doesn't look like the same issue 1765. It also may not be an
> > > ImageBundle issue, just can't be sure quiet yet.
>
> > > /kel
>