mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 07:25:23 +02:00
Bug 400073 - Indexer runs out of memory. An attempt to fix a memory
leak.
This commit is contained in:
parent
3b02e44d30
commit
f33ded195a
3 changed files with 60 additions and 41 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
* Copyright (c) 2005, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Thomas Corbat (IFS)
|
* Thomas Corbat (IFS)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -145,7 +146,12 @@ public class CPPClassSpecialization extends CPPSpecialization
|
||||||
|
|
||||||
private ICPPClassSpecializationScope specScope;
|
private ICPPClassSpecializationScope specScope;
|
||||||
private ObjectMap specializationMap= ObjectMap.EMPTY_MAP;
|
private ObjectMap specializationMap= ObjectMap.EMPTY_MAP;
|
||||||
private final ThreadLocal<Set<IBinding>> fInProgress= new ThreadLocal<Set<IBinding>>();
|
private final ThreadLocal<Set<IBinding>> fInProgress= new ThreadLocal<Set<IBinding>>() {
|
||||||
|
@Override
|
||||||
|
protected Set<IBinding> initialValue() {
|
||||||
|
return new HashSet<IBinding>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public CPPClassSpecialization(ICPPClassType specialized, IBinding owner,
|
public CPPClassSpecialization(ICPPClassType specialized, IBinding owner,
|
||||||
ICPPTemplateParameterMap argumentMap) {
|
ICPPTemplateParameterMap argumentMap) {
|
||||||
|
@ -164,23 +170,24 @@ public class CPPClassSpecialization extends CPPSpecialization
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinding specializeMember(IBinding original, IASTNode point) {
|
public IBinding specializeMember(IBinding original, IASTNode point) {
|
||||||
Set<IBinding> set;
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
IBinding result= (IBinding) specializationMap.get(original);
|
IBinding result= (IBinding) specializationMap.get(original);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
set= fInProgress.get();
|
|
||||||
if (set == null) {
|
|
||||||
set= new HashSet<IBinding>();
|
|
||||||
fInProgress.set(set);
|
|
||||||
}
|
|
||||||
if (!set.add(original))
|
|
||||||
return RecursionResolvingBinding.createFor(original, point);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IBinding result= CPPTemplates.createSpecialization(this, original, point);
|
IBinding result;
|
||||||
set.remove(original);
|
Set<IBinding> recursionProtectionSet= fInProgress.get();
|
||||||
|
try {
|
||||||
|
if (!recursionProtectionSet.add(original))
|
||||||
|
return RecursionResolvingBinding.createFor(original, point);
|
||||||
|
|
||||||
|
result= CPPTemplates.createSpecialization(this, original, point);
|
||||||
|
} finally {
|
||||||
|
recursionProtectionSet.remove(original);
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
IBinding concurrent= (IBinding) specializationMap.get(original);
|
IBinding concurrent= (IBinding) specializationMap.get(original);
|
||||||
if (concurrent != null)
|
if (concurrent != null)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2012 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2013 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -42,7 +42,12 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
public class CompositeCPPClassSpecialization extends CompositeCPPClassType implements ICPPClassSpecialization {
|
public class CompositeCPPClassSpecialization extends CompositeCPPClassType implements ICPPClassSpecialization {
|
||||||
private ObjectMap specializationMap;
|
private ObjectMap specializationMap;
|
||||||
private final ThreadLocal<Set<IBinding>> fInProgress= new ThreadLocal<Set<IBinding>>();
|
private final ThreadLocal<Set<IBinding>> fInProgress= new ThreadLocal<Set<IBinding>>() {
|
||||||
|
@Override
|
||||||
|
protected Set<IBinding> initialValue() {
|
||||||
|
return new HashSet<IBinding>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public CompositeCPPClassSpecialization(ICompositesFactory cf, ICPPClassType rbinding) {
|
public CompositeCPPClassSpecialization(ICompositesFactory cf, ICPPClassType rbinding) {
|
||||||
super(cf, rbinding);
|
super(cf, rbinding);
|
||||||
|
@ -103,21 +108,22 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
||||||
specializationMap= (ObjectMap) frag.putCachedResult(key, newMap, false);
|
specializationMap= (ObjectMap) frag.putCachedResult(key, newMap, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<IBinding> set;
|
|
||||||
synchronized (specializationMap) {
|
synchronized (specializationMap) {
|
||||||
IBinding result= (IBinding) specializationMap.get(original);
|
IBinding result= (IBinding) specializationMap.get(original);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
return result;
|
return result;
|
||||||
set= fInProgress.get();
|
|
||||||
if (set == null) {
|
|
||||||
set= new HashSet<IBinding>();
|
|
||||||
fInProgress.set(set);
|
|
||||||
}
|
}
|
||||||
if (!set.add(original))
|
|
||||||
|
IBinding newSpec;
|
||||||
|
Set<IBinding> recursionProtectionSet= fInProgress.get();
|
||||||
|
try {
|
||||||
|
if (!recursionProtectionSet.add(original))
|
||||||
return RecursionResolvingBinding.createFor(original, point);
|
return RecursionResolvingBinding.createFor(original, point);
|
||||||
|
|
||||||
|
newSpec= CPPTemplates.createSpecialization(this, original, point);
|
||||||
|
} finally {
|
||||||
|
recursionProtectionSet.remove(original);
|
||||||
}
|
}
|
||||||
IBinding newSpec= CPPTemplates.createSpecialization(this, original, point);
|
|
||||||
set.remove(original);
|
|
||||||
|
|
||||||
synchronized (specializationMap) {
|
synchronized (specializationMap) {
|
||||||
IBinding oldSpec= (IBinding) specializationMap.put(original, newSpec);
|
IBinding oldSpec= (IBinding) specializationMap.put(original, newSpec);
|
||||||
|
|
|
@ -14,6 +14,12 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
@ -44,12 +50,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bryan Wilkinson
|
* @author Bryan Wilkinson
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +67,12 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
|
|
||||||
private volatile ICPPClassScope fScope;
|
private volatile ICPPClassScope fScope;
|
||||||
private ObjectMap specializationMap; // Obtained from the synchronized PDOM cache
|
private ObjectMap specializationMap; // Obtained from the synchronized PDOM cache
|
||||||
private final ThreadLocal<Set<IBinding>> fInProgress= new ThreadLocal<Set<IBinding>>();
|
private final ThreadLocal<Set<IBinding>> fInProgress= new ThreadLocal<Set<IBinding>>() {
|
||||||
|
@Override
|
||||||
|
protected Set<IBinding> initialValue() {
|
||||||
|
return new HashSet<IBinding>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType,
|
public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType,
|
||||||
PDOMBinding specialized) throws CoreException {
|
PDOMBinding specialized) throws CoreException {
|
||||||
|
@ -132,21 +137,22 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
specializationMap= (ObjectMap) getPDOM().putCachedResult(key, newMap, false);
|
specializationMap= (ObjectMap) getPDOM().putCachedResult(key, newMap, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<IBinding> set;
|
|
||||||
synchronized (specializationMap) {
|
synchronized (specializationMap) {
|
||||||
IBinding result= (IBinding) specializationMap.get(original);
|
IBinding result= (IBinding) specializationMap.get(original);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
return result;
|
return result;
|
||||||
set= fInProgress.get();
|
|
||||||
if (set == null) {
|
|
||||||
set= new HashSet<IBinding>();
|
|
||||||
fInProgress.set(set);
|
|
||||||
}
|
}
|
||||||
if (!set.add(original))
|
|
||||||
|
IBinding newSpec;
|
||||||
|
Set<IBinding> recursionProtectionSet= fInProgress.get();
|
||||||
|
try {
|
||||||
|
if (!recursionProtectionSet.add(original))
|
||||||
return RecursionResolvingBinding.createFor(original, point);
|
return RecursionResolvingBinding.createFor(original, point);
|
||||||
|
|
||||||
|
newSpec= CPPTemplates.createSpecialization(this, original, point);
|
||||||
|
} finally {
|
||||||
|
recursionProtectionSet.remove(original);
|
||||||
}
|
}
|
||||||
IBinding newSpec= CPPTemplates.createSpecialization(this, original, point);
|
|
||||||
set.remove(original);
|
|
||||||
|
|
||||||
synchronized (specializationMap) {
|
synchronized (specializationMap) {
|
||||||
IBinding oldSpec= (IBinding) specializationMap.put(original, newSpec);
|
IBinding oldSpec= (IBinding) specializationMap.put(original, newSpec);
|
||||||
|
|
Loading…
Add table
Reference in a new issue