]> source.dussan.org Git - vaadin-framework.git/commitdiff
Another fix for #1384: Critical memory leak, every paintable/component/layout/event...
authorJani Laakso <jani.laakso@itmill.com>
Thu, 7 Feb 2008 13:11:13 +0000 (13:11 +0000)
committerJani Laakso <jani.laakso@itmill.com>
Thu, 7 Feb 2008 13:11:13 +0000 (13:11 +0000)
svn changeset:3728/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java

index ac9610018b1616187ca23588942a8a188d2abc20..531aa09ef049ecf38c9755f0776476afeedcbe45 100644 (file)
@@ -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</pre></body></html>");
             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());
         }
 
     }