diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2014-03-05 15:45:11 +0200 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2014-03-05 15:45:11 +0200 |
commit | 024692835d1e2af1a4053821959f03f8d5eb4fcb (patch) | |
tree | 00ec7145dbf1b3a0d21fba8c9434b80d4bed5c1d /client/src | |
parent | 46675661cd95f61e3173f33e7dcfeb32bc377f41 (diff) | |
download | vaadin-framework-024692835d1e2af1a4053821959f03f8d5eb4fcb.tar.gz vaadin-framework-024692835d1e2af1a4053821959f03f8d5eb4fcb.zip |
Fixes a memory leak on IE8 in LayoutManagerIE8 (#12688)
Change-Id: I9b2d2ff9513a9063de292fdf1e14b227e0ff4d76
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/com/vaadin/client/LayoutManager.java | 9 | ||||
-rw-r--r-- | client/src/com/vaadin/client/LayoutManagerIE8.java | 18 |
2 files changed, 24 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/LayoutManager.java b/client/src/com/vaadin/client/LayoutManager.java index 1ced003146..5b27031a29 100644 --- a/client/src/com/vaadin/client/LayoutManager.java +++ b/client/src/com/vaadin/client/LayoutManager.java @@ -75,6 +75,15 @@ public class LayoutManager { } /** + * Returns the application connection for this layout manager. + * + * @return connection + */ + protected ApplicationConnection getConnection() { + return connection; + } + + /** * Gets the layout manager associated with the given * {@link ApplicationConnection}. * diff --git a/client/src/com/vaadin/client/LayoutManagerIE8.java b/client/src/com/vaadin/client/LayoutManagerIE8.java index a692f126a2..b7973310db 100644 --- a/client/src/com/vaadin/client/LayoutManagerIE8.java +++ b/client/src/com/vaadin/client/LayoutManagerIE8.java @@ -19,8 +19,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.Node; import com.google.gwt.user.client.ui.RootPanel; /** @@ -39,6 +39,12 @@ public class LayoutManagerIE8 extends LayoutManager { private Map<Element, MeasuredSize> measuredSizes = new HashMap<Element, MeasuredSize>(); + // this method is needed to test for memory leaks (see + // LayoutMemoryUsageIE8ExtensionConnector) but can be private + private int getMeasuredSizesMapSize() { + return measuredSizes.size(); + } + @Override protected void setMeasuredSize(Element element, MeasuredSize measuredSize) { if (measuredSize != null) { @@ -62,12 +68,18 @@ public class LayoutManagerIE8 extends LayoutManager { @Override protected void cleanMeasuredSizes() { Profiler.enter("LayoutManager.cleanMeasuredSizes"); - Document document = RootPanel.get().getElement().getOwnerDocument(); + + // #12688: IE8 was leaking memory when adding&removing components. + // Uses IE specific logic to figure if an element has been removed from + // DOM or not. For this the parent element of the current UI is needed. + // For removed elements the measured size is discarded. + Node rootNode = getConnection().getUIConnector().getWidget() + .getElement().getParentNode(); Iterator<Element> i = measuredSizes.keySet().iterator(); while (i.hasNext()) { Element e = i.next(); - if (e.getOwnerDocument() != document) { + if (!rootNode.isOrHasChild(e)) { i.remove(); } } |