1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 310104 mem-leak: Don't cache ICProject / ICConfigurationDescription when IndexProviderManagerTests aren't running

This commit is contained in:
James Blackburn 2010-04-23 12:14:34 +00:00
parent 1e118a7e58
commit c01b11c194
3 changed files with 15 additions and 1 deletions

View file

@ -24,11 +24,15 @@ public class AbstractDummyProvider implements IReadOnlyPDOMProvider {
public AbstractDummyProvider() {} public AbstractDummyProvider() {}
public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) { public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
if (!DummyProviderTraces.getInstance().enabled)
return new IPDOMDescriptor[0];
DummyProviderTraces.getInstance().getCfgsTrace(getClass()).add(config); DummyProviderTraces.getInstance().getCfgsTrace(getClass()).add(config);
return new IPDOMDescriptor[0]; return new IPDOMDescriptor[0];
} }
public boolean providesFor(ICProject project) throws CoreException { public boolean providesFor(ICProject project) throws CoreException {
if (!DummyProviderTraces.getInstance().enabled)
return true;
DummyProviderTraces.getInstance().getProjectsTrace(getClass()).add(project); DummyProviderTraces.getInstance().getProjectsTrace(getClass()).add(project);
return true; return true;
} }

View file

@ -20,7 +20,10 @@ public class DummyProviderTraces {
static DummyProviderTraces instance = new DummyProviderTraces(); static DummyProviderTraces instance = new DummyProviderTraces();
public static DummyProviderTraces getInstance() { return instance; } public static DummyProviderTraces getInstance() { return instance; }
/** Flag indicates if test is enabled, so we should trace projects and configs */
public volatile boolean enabled;
private DummyProviderTraces() {} private DummyProviderTraces() {}
Map/*<String, List>*/ id2prjTrace= new HashMap(); Map/*<String, List>*/ id2prjTrace= new HashMap();

View file

@ -94,8 +94,15 @@ public class IndexProviderManagerTest extends IndexTestBase {
return suite(IndexProviderManagerTest.class); return suite(IndexProviderManagerTest.class);
} }
@Override
protected void setUp() throws Exception {
DPT.enabled = true;
super.setUp();
}
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
DPT.enabled = false;
IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager(); IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager();
ipm.reset(); ipm.startup(); ipm.reset(); ipm.startup();
} }