Retained references to PsiElements after project is closed

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!

6 comments
Comment actions Permalink

Could you upload sample dumps somewhere?

0
Comment actions Permalink

Yann, I've uploaded a heap dump here:

<link-removed>

I generated that heap dump by starting IntelliJ with my custom language plugin installed and jvisualvm attached, opening a small project, closing that project, forcing a few GCs, and then forcing the heap dump.

You'll see that there are retained references to ProjectImpl, ModuleImpl, ApexClassFile, and other leaf PsiElements like ApexNameIdentifier.

I sincerely appreciate anything you're able to find of use in there, and I apologize in advance if I'm missing something obvious!

Regards,
Scott

0
Comment actions Permalink

Could you please ZIP this file and upload it somewhere else than Google Docs, e.g. DropBox? Thanks. I failed to download two times.

0
Comment actions Permalink

Sure.  Sorry about that.  Try this:

<link-removed>

Let me know if you have any trouble getting that one,

Scott

0
Comment actions Permalink

OK got it. Definitely some problems there. Is it possible to look at the source-code of the plugin?

0
Comment actions Permalink

Unfortunately it's not an open source plugin.  I'm happy to use a support case to provide access to it temporarily if that helps.  Let me know how you'd like to proceed.

0

Please sign in to leave a comment.