Periodically clean caches and history to avoid Eclipse ‘rot’

UPDATE: this is a very old article, if you’d like updated information about Eclipse please allow me to recommend the Eclipse IDE 3.7 book which includes a lot of useful configuration tips.

Today, a quick one.

If you work with a lot of projects, opening multiple Java files and performing big searches and refactorings from time to time, you'll notice that Eclipse becomes increasingly slower. This is somewhat similar with the infamous 'Windows rot'. Except, this time you have solutions other that complete reinstall.

Deleting “workspace/.metadata directory” is such a solution, but a violent one, since you lose all your settings and 'non-code' work. And while the settings can still be exported and reimported after the clean restart of Eclipse, there definitively is some data (such as the “Run” list) which has to be rebuilt from scratch. And if the list has tens of items, that's your precious worktime which is lost.

A nicer, less invasive solution is to delete only the resource history and the JDT caching. That means deleting all the content of the directory “workspace/.metadata/.plugins/org.eclipse.core.resources/.history” (but not the directory itself) as well as *.index files from “workspace/.metadata/.plugins/org.eclipse.jdt.core” and “savedIndexNames.txt” from this same directory.

I've also learned that some hard Eclipse crashes as well as dubious plugin uninstalls (via directory deletions) migh completely bork the workspace, then Eclipse isn't even able to restart … again, the trick is to delete “workspace/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml” and restart with default workbench. (see also one of my older posts).

Tested with Eclipse \<=3.0M4 … YMMV