Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 111689 Details for
Bug 244849
[implementation] Memory leak in DeltaProcessingState#externalTimeStamps ?
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
244849.txt (text/plain), 9.51 KB, created by
Jerome Lanneluc
on 2008-09-04 13:10:42 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2008-09-04 13:10:42 EDT
Size:
9.51 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/JavaProject.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java,v >retrieving revision 1.411 >diff -u -r1.411 JavaProject.java >--- model/org/eclipse/jdt/internal/core/JavaProject.java 1 Sep 2008 08:53:56 -0000 1.411 >+++ model/org/eclipse/jdt/internal/core/JavaProject.java 4 Sep 2008 17:09:37 -0000 >@@ -440,9 +440,6 @@ > // compute the pkg fragment roots > info.setChildren(computePackageFragmentRoots(resolvedClasspath, false, null /*no reverse map*/)); > >- // remember the timestamps of external libraries the first time they are looked up >- getPerProjectInfo().rememberExternalLibTimestamps(); >- > return true; > } > >Index: model/org/eclipse/jdt/internal/core/JavaModelManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java,v >retrieving revision 1.408 >diff -u -r1.408 JavaModelManager.java >--- model/org/eclipse/jdt/internal/core/JavaModelManager.java 1 Sep 2008 08:53:56 -0000 1.408 >+++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 4 Sep 2008 17:09:36 -0000 >@@ -1055,6 +1055,22 @@ > return null; > return this.resolvedClasspath; > } >+ >+ public void forgetExternalTimestamps() { >+ IClasspathEntry[] classpath = this.resolvedClasspath; >+ if (classpath == null) return; >+ Map externalTimeStamps = JavaModelManager.getJavaModelManager().deltaState.getExternalLibTimeStamps(); >+ HashMap rootInfos = JavaModelManager.getDeltaState().otherRoots; >+ for (int i = 0, length = classpath.length; i < length; i++) { >+ IClasspathEntry entry = classpath[i]; >+ if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { >+ IPath path = entry.getPath(); >+ if (rootInfos.get(path) == null) { >+ externalTimeStamps.remove(path); >+ } >+ } >+ } >+ } > > public void rememberExternalLibTimestamps() { > IClasspathEntry[] classpath = this.resolvedClasspath; >@@ -3417,6 +3433,7 @@ > PerProjectInfo info= (PerProjectInfo) this.perProjectInfos.get(project); > if (info != null) { > this.perProjectInfos.remove(project); >+ info.forgetExternalTimestamps(); > } > } > } >@@ -3877,7 +3894,6 @@ > if (!JavaProject.hasJavaNature(savedProject)) return; // ignore > PerProjectInfo info = getPerProjectInfo(savedProject, true /* create info */); > saveState(info, context); >- info.rememberExternalLibTimestamps(); > return; > } > >@@ -3891,7 +3907,6 @@ > try { > PerProjectInfo info = (PerProjectInfo) iterator.next(); > saveState(info, context); >- info.rememberExternalLibTimestamps(); > } catch (CoreException e) { > if (vStats == null) > vStats= new ArrayList(); >Index: model/org/eclipse/jdt/internal/core/DeltaProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java,v >retrieving revision 1.326 >diff -u -r1.326 DeltaProcessor.java >--- model/org/eclipse/jdt/internal/core/DeltaProcessor.java 27 Aug 2008 08:59:19 -0000 1.326 >+++ model/org/eclipse/jdt/internal/core/DeltaProcessor.java 4 Sep 2008 17:09:35 -0000 >@@ -1013,8 +1013,10 @@ > if (elementType == IJavaElement.JAVA_PROJECT) { > // project add is handled by JavaProject.configure() because > // when a project is created, it does not yet have a java nature >- if (delta != null && JavaProject.hasJavaNature((IProject)delta.getResource())) { >+ IProject project; >+ if (delta != null && JavaProject.hasJavaNature(project = (IProject)delta.getResource())) { > addToParentInfo(element); >+ this.manager.getPerProjectInfo(project, false /* don't create info */).rememberExternalLibTimestamps(); > if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) { > Openable movedFromElement = (Openable)element.getJavaModel().getJavaProject(delta.getMovedFromPath().lastSegment()); > currentDelta().movedTo(element, movedFromElement); >Index: model/org/eclipse/jdt/internal/core/ClasspathChange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathChange.java,v >retrieving revision 1.18 >diff -u -r1.18 ClasspathChange.java >--- model/org/eclipse/jdt/internal/core/ClasspathChange.java 27 Jun 2008 16:03:51 -0000 1.18 >+++ model/org/eclipse/jdt/internal/core/ClasspathChange.java 4 Sep 2008 17:09:35 -0000 >@@ -333,26 +333,6 @@ > } > } > addClasspathDeltas(delta, pkgFragmentRoots, IJavaElementDelta.F_REMOVED_FROM_CLASSPATH); >- >- // remember timestamp of jars that were removed (in case they are added as external jar in the same operation) >- for (int j = 0, length = pkgFragmentRoots.length; j < length; j++) { >- PackageFragmentRoot root = pkgFragmentRoots[j]; >- if (root.isArchive() && !root.isExternal()) { >- URI location = root.resource().getLocationURI(); >- File file = null; >- try { >- IFileStore fileStore = EFS.getStore(location); >- file = fileStore.toLocalFile(EFS.NONE, null); >- } catch (CoreException e) { >- // continue >- } >- if (file == null) >- continue; >- long timeStamp = DeltaProcessor.getTimeStamp(file); >- IPath externalPath = new org.eclipse.core.runtime.Path(file.getAbsolutePath()); >- state.getExternalLibTimeStamps().put(externalPath, new Long(timeStamp)); >- } >- } > } else { > // remote project changes > if (this.oldResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) { >Index: model/org/eclipse/jdt/internal/core/DeltaProcessingState.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java,v >retrieving revision 1.50 >diff -u -r1.50 DeltaProcessingState.java >--- model/org/eclipse/jdt/internal/core/DeltaProcessingState.java 27 Jun 2008 16:03:51 -0000 1.50 >+++ model/org/eclipse/jdt/internal/core/DeltaProcessingState.java 4 Sep 2008 17:09:35 -0000 >@@ -507,18 +507,33 @@ > > public void saveExternalLibTimeStamps() throws CoreException { > if (this.externalTimeStamps == null) return; >+ >+ // cleanup to avoid any leak ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=244849 ) >+ HashSet toRemove = new HashSet(); >+ if (this.roots != null) { >+ Enumeration keys = this.externalTimeStamps.keys(); >+ while (keys.hasMoreElements()) { >+ Object key = keys.nextElement(); >+ if (this.roots.get(key) == null) { >+ toRemove.add(key); >+ } >+ } >+ } >+ > File timestamps = getTimeStampsFile(); > DataOutputStream out = null; > try { > out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(timestamps))); >- out.writeInt(this.externalTimeStamps.size()); >+ out.writeInt(this.externalTimeStamps.size() - toRemove.size()); > Iterator entries = this.externalTimeStamps.entrySet().iterator(); > while (entries.hasNext()) { > Map.Entry entry = (Map.Entry) entries.next(); > IPath key = (IPath) entry.getKey(); >- out.writeUTF(key.toPortableString()); >- Long timestamp = (Long) entry.getValue(); >- out.writeLong(timestamp.longValue()); >+ if (!toRemove.contains(key)) { >+ out.writeUTF(key.toPortableString()); >+ Long timestamp = (Long) entry.getValue(); >+ out.writeLong(timestamp.longValue()); >+ } > } > } catch (IOException e) { > IStatus status = new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, IStatus.ERROR, "Problems while saving timestamps", e); //$NON-NLS-1$ >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java,v >retrieving revision 1.37 >diff -u -r1.37 ExternalJarDeltaTests.java >--- src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java 27 Jun 2008 16:02:40 -0000 1.37 >+++ src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java 4 Sep 2008 17:09:39 -0000 >@@ -533,7 +533,7 @@ > "Unexpected delta", > "P[*]: {CHILDREN | CONTENT | RAW CLASSPATH CHANGED | RESOLVED CLASSPATH CHANGED}\n"+ > " foo.jar[*]: {REMOVED FROM CLASSPATH}\n"+ >- " "+externalFooPathString+"[*]: {ADDED TO CLASSPATH}\n"+ >+ " "+externalFooPathString+"[+]: {}\n"+ > " ResourceDelta(/P/.classpath)[*]\n"+ > "\n"+ > "P[*]: {CHILDREN}\n"+ >Index: src/org/eclipse/jdt/core/tests/model/ClasspathTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java,v >retrieving revision 1.182 >diff -u -r1.182 ClasspathTests.java >--- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 1 Sep 2008 14:46:52 -0000 1.182 >+++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 4 Sep 2008 17:09:39 -0000 >@@ -710,7 +710,7 @@ > "Unexpected delta", > "P[*]: {CHILDREN | CONTENT | RAW CLASSPATH CHANGED | RESOLVED CLASSPATH CHANGED}\n" + > " <project root>[*]: {REMOVED FROM CLASSPATH}\n" + >- " "+ getExternalJCLPathString() + "[*]: {ADDED TO CLASSPATH}\n" + >+ " "+ getExternalJCLPathString() + "[+]: {}\n" + > " ResourceDelta(/P/.classpath)[*]" > ); > } finally {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 244849
:
110604
|
111688
| 111689