From: Jani Laakso Date: Thu, 7 Feb 2008 13:11:13 +0000 (+0000) Subject: Another fix for #1384: Critical memory leak, every paintable/component/layout/event... X-Git-Tag: 6.7.0.beta1~5092 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=79d11d91f016e6212c3b7c1de4917db08fff8aa4;p=vaadin-framework.git Another fix for #1384: Critical memory leak, every paintable/component/layout/event/listener.. leaks within the session svn changeset:3728/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index ac9610018b..531aa09ef0 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -272,6 +272,16 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { requireLocale(application.getLocale().toString()); } else { + // remove detached components from paintableIdMap so they + // can be GC'ed + for (Iterator it = paintableIdMap.keySet().iterator(); it + .hasNext();) { + Component p = (Component) it.next(); + if (p.getApplication() == null) { + idPaintableMap.remove(paintableIdMap.get(p)); + it.remove(); + } + } paintables = getDirtyComponents(window); } if (paintables != null) { @@ -431,20 +441,8 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { err.write("\n"); err.close(); } finally { - synchronized (application) { - for (Iterator it = paintableIdMap.keySet().iterator(); it - .hasNext();) { - Component p = (Component) it.next(); - if (p.getApplication() == null) { - - idPaintableMap.remove(paintableIdMap.get(p)); - it.remove(); - } - } - - Log.debug("paintableIdMap.size=" + paintableIdMap.size() - + ", idPaintableMap.size=" + idPaintableMap.size()); - } + Log.debug("paintableIdMap.size=" + paintableIdMap.size() + + ", idPaintableMap.size=" + idPaintableMap.size()); } }