by experiments with clearing the mavenProject.setProjectBuildingRequest field, I've arrived at significantly reduced number of org.apache.maven.Model instances in the running IDE which has significant consequences on memory performance.
further investigation is need what is the field used for and if it's entirely save to clear it.
the only code that we use requiring the request present is MavenProject.getParent() call which is present in multiple spots in out codebase.
getParent() throws IllegalStateException when the request is not present and on all places in our codebase we catch that exception. The result after clearing the field is that some functionality doesn't work as previously did. Mostly collateral stuff but still..
another point retaining past raw models is the ModelBuildingException thrown if something goes wrong.
http://hg.netbeans.org/core-main/rev/ec35eae2bb89 clears the ProjectBuildingRequest in MavenProject instance when loading projects. Additionally some other places calling relatively expensive code like MavenProject.getParent() or MavenEmbedder.createModelLineage are now using code that allows throwing out the object tree when not used and in some cases avoids creating the object tree altogether.
Perhaps it is satisfying to see that someone is waiting for this :)
See bug 214740.
Integrated into 'main-golden', will be available in build *201207110002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Milos Kleint <email@example.com>
Log: #215159, #215127 clear projectBuildingRequest from Mavenproject instance which seems to b the point effectively referencing a RepositoryCache holding multiple Model object.
Get rid of calls to MavenProject.getParent() and replace it with a method more suited for sparse invokations with throwaway results.
Introduce ModelDescription to MavenEmbedder that contains various information collected while loading project's MavenProject, allowing to reduce the number of repeated queries to the embedder environment.
*** Bug 215815 has been marked as a duplicate of this bug. ***
*** Bug 215116 has been marked as a duplicate of this bug. ***