I noticed a bit back that there seemed to be a memory leak in my custom language plugin, in particular when switching back and forth between projects. I finally took some time to profile this a bit and found that PsiElements including the PsiFiles are still in-memory after the project has been closed even after forcing the garbage collector repeatedly.
I do normally cache things pretty aggressively using CachedValuesManager and UserDataHolder as appropriate, so I started peeling things back there. I've temporarily removed all usages of CachedValuesManager. I've verified that I have absolutely no static caches anywhere. I've confirmed that I only call UserDataHolder.putUserData() explicitly on Projects and Modules which I assume would be evicted along with the Project and Module objects, though those are still showing up in the heap dump even though no project is open any longer.
Of course, I'm still assuming this is my own issue, but does anyone have any thoughts on what else might be holding onto these things? As I'm sure you can imagine, trying to walk references in the heap dump looking for a smoking gun isn't proving very fruitful given how extensive these PSI object graphs can become.
Thanks much for any thoughts!