cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r568930 - /cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/event/DispatchQueue.java
Date Thu, 23 Aug 2007 10:59:38 GMT
Author: aadamchik
Date: Thu Aug 23 03:59:37 2007
New Revision: 568930

URL: http://svn.apache.org/viewvc?rev=568930&view=rev
Log:
CAY-770 bug / memory leak in DispatchQueue and EventManager

Modified:
    cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/event/DispatchQueue.java

Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/event/DispatchQueue.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/event/DispatchQueue.java?rev=568930&r1=568929&r2=568930&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/event/DispatchQueue.java
(original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/event/DispatchQueue.java
Thu Aug 23 03:59:37 2007
@@ -95,12 +95,28 @@
     }
 
     synchronized void addInvocation(Invocation invocation, Object sender) {
+        Collection invocations;
+
         if (sender == null) {
-            subjectInvocations.add(invocation);
+            invocations = subjectInvocations;
         }
         else {
-            invocationsForSender(sender, true).add(invocation);
+            invocations = invocationsForSender(sender, true);
         }
+
+        // perform maintenance of the given invocations set, as failure to do taht can
+        // result in a memory leak per CAY-770. This seemed to happen when lots of
+        // invocations got registered, but no events where dispatched (hence the stale
+        // inocation removal during dispatch did not happen)
+        Iterator it = invocations.iterator();
+        while (it.hasNext()) {
+            Invocation i = (Invocation) it.next();
+            if (i.getTarget() == null) {
+                it.remove();
+            }
+        }
+
+        invocations.add(invocation);
     }
 
     synchronized boolean removeInvocations(Object listener, Object sender) {



Mime
View raw message