Memory leak in ImageBundle on IE

26 views
Skip to first unread message

dflorey

unread,
Feb 11, 2008, 5:42:55 AM2/11/08
to Google Web Toolkit Contributors
Hi,
I've observed a memory leak on IE when creating Images using
ImageBundle. As GWT is a great tool to build non leaking IE apps this
looks like a serious issue to me and theirfore I'm posting this into
the contributors group.
I've assembled a showcase that makes it easy to reproduce this bug
(?).

http://gwt-issues.floreysoft.com/

Sources can be found here:

http://gwt-issues.floreysoft.com/MemLeak-src.zip

Issue opened:

http://code.google.com/p/google-web-toolkit/issues/detail?id=2058&sort=-id

Cheers,
Daniel

Rajeev Dayal

unread,
Feb 11, 2008, 9:55:54 AM2/11/08
to Google-Web-Tool...@googlegroups.com
Hey Daniel,

Thanks for reporting this.

This is a known issue. Check out issue #1765 for more details. We are targeting a fix for this problem in the 1.5 release. In fact, a patch has been submitted by Kelly Norton already, which is awaiting my review :). His patch should definitely help with this problem.


Thanks,
Rajeev

dflorey

unread,
Feb 12, 2008, 5:38:10 AM2/12/08
to Google Web Toolkit Contributors
Hey, that's great news!
Thanks,Daniel

On 11 Feb., 15:55, "Rajeev Dayal" <rda...@google.com> wrote:
> Hey Daniel,
>
> Thanks for reporting this.
>
> This is a known issue. Check out issue #1765 for more details. We are
> targeting a fix for this problem in the 1.5 release. In fact, a patch has
> been submitted by Kelly Norton already, which is awaiting my review :). His
> patch should definitely help with this problem.
>
> Thanks,
> Rajeev
>
> On Feb 11, 2008 5:42 AM, dflorey <daniel.flo...@gmail.com> wrote:
>
>
>
>
>
> > Hi,
> > I've observed a memory leak on IE when creating Images using
> > ImageBundle. As GWT is a great tool to build non leaking IE apps this
> > looks like a serious issue to me and theirfore I'm posting this into
> > the contributors group.
> > I've assembled a showcase that makes it easy to reproduce this bug
> > (?).
>
> >http://gwt-issues.floreysoft.com/
>
> > Sources can be found here:
>
> >http://gwt-issues.floreysoft.com/MemLeak-src.zip
>
> > Issue opened:
>
> >http://code.google.com/p/google-web-toolkit/issues/detail?id=2058&sor...
>
> > Cheers,
> > Daniel- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

dflorey

unread,
Feb 12, 2008, 5:44:16 AM2/12/08
to Google Web Toolkit Contributors
I just read the 1765 bugreport and I'm not sure if it addresses the
issue that memory will not be released after removing images from the
app.
My problem is not the initial memory consumption, but the leaking
memory on IE. So if you add/remove images using my demo app you'll see
memory increase dramatically.
> > - Zitierten Text anzeigen -- Zitierten Text ausblenden -

Kelly Norton

unread,
Feb 19, 2008, 7:45:30 PM2/19/08
to Google-Web-Tool...@googlegroups.com
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
ie-leak.png

Joel Webber

unread,
Feb 20, 2008, 10:12:05 AM2/20/08
to Google-Web-Tool...@googlegroups.com
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.

Kelly Norton

unread,
Feb 20, 2008, 10:17:23 AM2/20/08
to Google-Web-Tool...@googlegroups.com
I'll post both versions of the test app this afternoon.

/kel
--
If you received this communication by mistake, you are entitled to one free ice cream cone on me. Simply print out this email including all relevant SMTP headers and present them at my desk to claim your creamy treat. We'll have a laugh at my emailing incompetence, and play a game of ping pong. (offer may not be valid in all States).

Peter Blazejewicz

unread,
Feb 20, 2008, 6:54:33 PM2/20/08
to Google Web Toolkit Contributors
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
>
Reply all
Reply to author
Forward
0 new messages