| Summary: | cache not cleared on buildpath modification | ||
|---|---|---|---|
| Product: | [Technology] DLTK | Reporter: | Simon Bernard <sbernard> |
| Component: | Common | Assignee: | dltk.common-inbox <dltk.common-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | alex.panchenko, contact |
| Version: | 3.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
Cache size is limited, so memory leak is not the case. Old entries are removed when the cache size limit is reached. Btw, probably it's not that important to clear the cache when folder is removed from the buildpath, as files content is still the same. But I have two remarks: 1) the code I show seems to never work (it seems to always raise a model exception). So if the decision is to do not support modification of classpath this code should be deleted. 2) Idealy, if the file is no more in the buildpath, the file should be remove from cache. Eventually, we could think that if we remove the file from the buildpath, we could keep it in cache as long as it is in the workspace. But when we will remove this file from workspace it will not be remove from cache because the file is no more a model element (so we have not notification) In this case, the cache is bigger than it should be but as the size is limited it's perhaps not that important. |
This problem could perhaps produce a memory leak. In the class org.eclipse.dltk.internal.core.SourceModuleInfoCache, there are the management of DLTK model cache. When a resource is remove from the buildpath, we go in this part of code (line 112) : ========================================================================== if (element.getElementType() == ISourceModule.PROJECT_FRAGMENT) { if (delta.getAffectedChildren().length == 0) { IProjectFragment fragment = (IProjectFragment) element; try { fragment.accept(new IModelElementVisitor() { public boolean visit(IModelElement element) { if (element.getElementType() == ISourceModule.SOURCE_MODULE) { SourceModuleInfoCache.this.remove((ISourceModule) element); return false; } return true; } }); } catch (ModelException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); } } } } =========================================================================== but sourcemodule is never removed from cache because a modelException is raised : org.eclipse.dltk.core.ModelException: src [in myapp] is not on its project's build path. To Reproduce that : 1) create a folder 2) add a source file 3) add the folder to the buildpath 4) remove the foler from the buildpath ==> the exception is raised, and the sourceModule don't removed from cache A solution could be to have a more precise information in the IModelElementDelta. if we have all the ISourceModule which will be removed from project cause of classpath modification. It will be not necessary to traverse the projectfragement.