Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2008-01-31 11:17:28 +0000
committerAnton Leherbauer2008-01-31 11:17:28 +0000
commit645d096b609ed8f39b01146ee5b31e238c93e7de (patch)
tree31be29bb609ac297c2ee5613d60e4bb2dce2b886 /core/org.eclipse.cdt.core/model/org
parente88356657e1a097a98e0025186c11c6ef7a46dff (diff)
downloadorg.eclipse.cdt-645d096b609ed8f39b01146ee5b31e238c93e7de.tar.gz
org.eclipse.cdt-645d096b609ed8f39b01146ee5b31e238c93e7de.tar.xz
org.eclipse.cdt-645d096b609ed8f39b01146ee5b31e238c93e7de.zip
Fix for 212998: CModelManager consumes a lot of memory during project refresh
Diffstat (limited to 'core/org.eclipse.cdt.core/model/org')
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java18
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java20
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java3
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/LRUCache.java8
4 files changed, 26 insertions, 23 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
index 17e8fa174a1..f1b1f0dd0f0 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 QNX Software Systems and others.
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
* 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
@@ -91,7 +91,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
/**
* Used to convert <code>IResourceDelta</code>s into <code>ICElementDelta</code>s.
*/
- protected DeltaProcessor fDeltaProcessor = new DeltaProcessor();
+ protected final DeltaProcessor fDeltaProcessor = new DeltaProcessor();
/**
* Queue of deltas created explicitly by the C Model that
@@ -101,7 +101,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
/**
* Queue of reconcile deltas on working copies that have yet to be fired.
- * This is a table form IWorkingCopy to IJavaElementDelta
+ * This is a table form IWorkingCopy to ICElementDelta
*/
HashMap reconcileDeltas = new HashMap();
@@ -902,7 +902,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
private void firePreAutoBuildDelta(ICElementDelta deltaToNotify,
IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
- if (VERBOSE) {
+ if (Util.VERBOSE_DELTA) {
System.out.println("FIRING PRE_AUTO_BUILD Delta [" + Thread.currentThread() + "]:"); //$NON-NLS-1$//$NON-NLS-2$
System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$
}
@@ -914,7 +914,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
private void firePostChangeDelta(ICElementDelta deltaToNotify, IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
// post change deltas
- if (VERBOSE) {
+ if (Util.VERBOSE_DELTA) {
System.out.println("FIRING POST_CHANGE Delta [" + Thread.currentThread() + "]:"); //$NON-NLS-1$//$NON-NLS-2$
System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$
}
@@ -927,7 +927,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
private void fireReconcileDelta(IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
ICElementDelta deltaToNotify = mergeDeltas(this.reconcileDeltas.values());
- if (VERBOSE) {
+ if (Util.VERBOSE_DELTA) {
System.out.println("FIRING POST_RECONCILE Delta [" + Thread.currentThread() + "]:"); //$NON-NLS-1$//$NON-NLS-2$
System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$
}
@@ -941,7 +941,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
private void fireShiftEvent(ICElementDelta deltaToNotify, IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
// post change deltas
- if (VERBOSE) {
+ if (Util.VERBOSE_DELTA) {
System.out.println("FIRING POST_SHIFT event [" + Thread.currentThread() + "]:"); //$NON-NLS-1$//$NON-NLS-2$
System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$
}
@@ -959,7 +959,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
if (listenerMask == null || (listenerMask[i] & eventType) != 0) {
final IElementChangedListener listener = listeners[i];
long start = -1;
- if (VERBOSE) {
+ if (Util.VERBOSE_DELTA) {
System.out.print("Listener #" + (i + 1) + "=" + listener.toString());//$NON-NLS-1$//$NON-NLS-2$
start = System.currentTimeMillis();
}
@@ -974,7 +974,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
listener.elementChanged(extraEvent);
}
});
- if (VERBOSE) {
+ if (Util.VERBOSE_DELTA) {
System.out.println(" -> " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
index aba3921f727..75065c953af 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* 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
@@ -35,24 +35,17 @@ import org.eclipse.core.runtime.IPath;
* It also does some processing on the <code>CElement</code>s involved
* (e.g. closing them or updating classpaths).
*/
-public class DeltaProcessor {
+final class DeltaProcessor {
/**
* The <code>CElementDelta</code> corresponding to the <code>IResourceDelta</code> being translated.
*/
- protected CElementDelta fCurrentDelta;
-
- /* The C element that was last created (see createElement(IResource).
- * This is used as a stack of C elements (using getParent() to pop it, and
- * using the various get*(...) to push it. */
- ICElement currentElement;
+ private CElementDelta fCurrentDelta;
static final ICElementDelta[] NO_DELTA = new ICElementDelta[0];
- public static boolean VERBOSE = false;
-
// Hold on the element bein renamed.
- ICElement movedFromElement = null;
+ private ICElement movedFromElement = null;
/**
* Creates the create corresponding to this resource.
@@ -440,7 +433,10 @@ public class DeltaProcessor {
traverseDelta(root, delta); // traverse delta
translatedDeltas[i] = fCurrentDelta;
}
- return filterRealDeltas(translatedDeltas);
+ ICElementDelta[] filteredDeltas= filterRealDeltas(translatedDeltas);
+ // release deltas
+ fCurrentDelta= null;
+ return filteredDeltas;
} finally {
}
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java
index ca6c77ff95e..30d03da8c39 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* 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
@@ -40,6 +40,7 @@ public class Util implements ICLogConstants {
public static boolean VERBOSE_PARSER = false;
public static boolean VERBOSE_SCANNER = false;
public static boolean VERBOSE_MODEL = false;
+ public static boolean VERBOSE_DELTA = false;
public static boolean PARSER_EXCEPTIONS= false;
public static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/LRUCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/LRUCache.java
index d2cb22735b5..5298eb9958c 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/LRUCache.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/LRUCache.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* 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
@@ -231,6 +231,12 @@ public class LRUCache implements Cloneable {
return fEntryTable.keys();
}
+ /**
+ * Tests if this cache is empty.
+ */
+ public boolean isEmpty() {
+ return fEntryTable.isEmpty();
+ }
/**
* Returns an enumeration that iterates over all the keys and values
* currently in the cache.

Back to the top