Ctf: add removeIterator() to prevent OutOfMemory exception (Bug 414998)
authorSimon Delisle <simon.delisle@ericsson.com>
Wed, 14 Aug 2013 18:35:31 +0000 (14:35 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 15 Aug 2013 18:10:54 +0000 (14:10 -0400)
Change-Id: I0a42a1b4d7eb14b37bc97471dba1b4aae44d2f4c
Signed-off-by: Simon Delisle <simon.delisle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/15487
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIteratorManager.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfContext.java

index 2d85af83686c1afd3c41994ed6f69b65969704ef..65fac21e59080277a60dded2c8dec51d633085ac 100644 (file)
@@ -6,7 +6,9 @@
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
- * Contributors: Matthew Khouzam - Initial API and implementation
+ * Contributors:
+ *   Matthew Khouzam - Initial API and implementation
+ *   Simon Delisle - Added a method to remove the iterator
  *******************************************************************************/
 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
 
@@ -71,6 +73,22 @@ public abstract class CtfIteratorManager {
             final CtfTmfContext ctx) {
         return map.get(trace).getIterator(ctx);
     }
+
+    /**
+     * Remove an iterator for a given trace and context
+     *
+     * @param trace
+     *            the trace
+     * @param ctx
+     *            the context
+     * @since 2.1
+     */
+    public static synchronized void removeIterator(final CtfTmfTrace trace, final CtfTmfContext ctx) {
+        CtfTraceManager traceManager = map.get(trace);
+        if (traceManager != null) {
+            traceManager.removeIterator(ctx);
+        }
+    }
 }
 
 /**
@@ -154,6 +172,11 @@ class CtfTraceManager {
         return retVal;
     }
 
+    public void removeIterator(CtfTmfContext context) {
+        fMap.remove(context);
+        fRandomAccess.remove(context);
+    }
+
     /**
      * Add a pair of context and element to the hashmap and the arraylist.
      *
index b1ef6d79559a2f8479c37527276aafb2570815e9..df2076b5e196114e36543581d30aec10ba1a84ca 100644 (file)
@@ -6,7 +6,9 @@
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
- * Contributors: Matthew Khouzam - Initial API and implementation
+ * Contributors:
+ *   Matthew Khouzam - Initial API and implementation
+ *   Simon Delisle - Remove the iterator in dispose()
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
@@ -137,7 +139,7 @@ public class CtfTmfContext implements ITmfContext {
 
     @Override
     public void dispose() {
-        // do nothing
+        CtfIteratorManager.removeIterator(fTrace, this);
     }
 
     /**
This page took 0.026611 seconds and 5 git commands to generate.