From 4c9f2944b123ac584313bf57cf039cbff8c5176b Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Wed, 3 Oct 2012 15:32:53 -0400 Subject: [PATCH] Fix for bug 390841: Experiment does not dispose trace contexts. Change-Id: Ib2ac07efc2f4b4efbb15971bbaa48401997fa215 Reviewed-on: https://git.eclipse.org/r/8002 Tested-by: Hudson CI Reviewed-by: Patrick Tasse IP-Clean: Patrick Tasse Tested-by: Patrick Tasse --- .../tmf/core/trace/TmfExperimentContext.java | 11 +++++++++++ .../linuxtools/tmf/core/trace/TmfExperiment.java | 13 ++----------- .../eclipse/linuxtools/tmf/core/trace/TmfTrace.java | 2 ++ .../tmf/ui/parsers/custom/CustomTxtTrace.java | 6 +++--- .../tmf/ui/parsers/custom/CustomXmlTrace.java | 6 +++--- .../tmf/ui/viewers/events/TmfEventsTable.java | 1 + 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentContext.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentContext.java index 2ea22050bf..816db8ba6f 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentContext.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentContext.java @@ -100,6 +100,17 @@ public class TmfExperimentContext extends TmfContext { setLastTrace(other.fLastTraceRead); } + /* (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext#dispose() + */ + @Override + public void dispose() { + for (ITmfContext context : fContexts) { + context.dispose(); + } + super.dispose(); + } + /* (non-Javadoc) * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext#clone() */ diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java index b4f85fa0f1..43a88371c1 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java @@ -78,10 +78,6 @@ public class TmfExperiment extends TmfTrace implements I */ private IFile fBookmarksFile; - - // Saved experiment context (optimization) - private TmfExperimentContext fExperimentContext; - // ------------------------------------------------------------------------ // Construction // ------------------------------------------------------------------------ @@ -206,6 +202,7 @@ public class TmfExperiment extends TmfTrace implements I public ITmfTimestamp getTimestamp(final int index) { final ITmfContext context = seekEvent(index); final ITmfEvent event = getNext(context); + context.dispose(); return (event != null) ? event.getTimestamp() : null; } @@ -252,11 +249,6 @@ public class TmfExperiment extends TmfTrace implements I } - // Check if we are already at the right index - if ((fExperimentContext != null) && fExperimentContext.getRank() == request.getIndex()) { - return fExperimentContext; - } - return seekEvent(request.getIndex()); } @@ -303,7 +295,6 @@ public class TmfExperiment extends TmfTrace implements I context.setLastTrace(TmfExperimentContext.NO_TRACE); context.setRank((location == null) ? 0 : ITmfContext.UNKNOWN_RANK); - fExperimentContext = context; return context; } @@ -412,7 +403,6 @@ public class TmfExperiment extends TmfTrace implements I location.getLocation().getLocations()[trace] = traceContext.getLocation().clone(); } - fExperimentContext = expContext.clone(); processEvent(event); } } @@ -443,6 +433,7 @@ public class TmfExperiment extends TmfTrace implements I if (getStreamingInterval() == 0) { final ITmfContext context = seekEvent(0); final ITmfEvent event = getNext(context); + context.dispose(); if (event == null) { return; } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java index a1ccadb03e..26c25e2396 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java @@ -484,9 +484,11 @@ public abstract class TmfTrace extends TmfEventProvider final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype... ITmfEvent event = getNext(nextEventContext); while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) { + context.dispose(); context = nextEventContext.clone(); event = getNext(nextEventContext); } + nextEventContext.dispose(); if (event == null) { context.setLocation(null); context.setRank(ITmfContext.UNKNOWN_RANK); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java index 4f3ddcc67e..270a2e2134 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2010 Ericsson - * + * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Patrick Tasse - Initial API and implementation *******************************************************************************/ @@ -171,7 +171,7 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEven @Override public synchronized CustomTxtEvent getNext(final ITmfContext context) { - final ITmfContext savedContext = context.clone(); + final ITmfContext savedContext = new TmfContext(context.getLocation(), context.getRank()); final CustomTxtEvent event = parse(context); if (event != null) { updateAttributes(savedContext, event.getTimestamp()); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java index 418487c308..df39f71c30 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2010 Ericsson - * + * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Patrick Tasse - Initial API and implementation *******************************************************************************/ @@ -176,7 +176,7 @@ public class CustomXmlTrace extends TmfTrace implements ITmfEven @Override public synchronized CustomXmlEvent getNext(final ITmfContext context) { - final ITmfContext savedContext = context.clone(); + final ITmfContext savedContext = new TmfContext(context.getLocation(), context.getRank()); final CustomXmlEvent event = parse(context); if (event != null) { updateAttributes(savedContext, event.getTimestamp()); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java index edf7cc399e..e114a895d2 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java @@ -1848,6 +1848,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, // Get the rank of the selected event in the table final ITmfContext context = fTrace.seekEvent(timestamp); final long rank = context.getRank(); + context.dispose(); fSelectedRank = rank; fTable.getDisplay().asyncExec(new Runnable() { -- 2.34.1