This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 206274 - org.netbeans.modules.websvc.rest.model.impl.Utils.checkForJsr311Bootstrap invokes Trees.getTree
Summary: org.netbeans.modules.websvc.rest.model.impl.Utils.checkForJsr311Bootstrap inv...
Status: VERIFIED FIXED
Alias: None
Product: webservices
Classification: Unclassified
Component: REST (show other bugs)
Version: 7.2
Hardware: PC Linux
: P2 normal (vote)
Assignee: Denis Anisimov
URL:
Keywords: PERFORMANCE
Depends on: 201039
Blocks: 206074
  Show dependency tree
 
Reported: 2011-12-12 15:01 UTC by Jan Lahoda
Modified: 2012-02-17 14:53 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Lahoda 2011-12-12 15:01:56 UTC
While looking at the heap dump from bug #206074, we have seen a lot of JCCompilationUnits, which represent whole parsed files.

This seems to be partially caused by org.netbeans.modules.websvc.rest.model.impl.Utils.checkForJsr311Bootstrap, which invokes Trees.getTree on a lot of Elements. As this call will try to find the source file and parse it, this is a quite expensive call and will keep the parsed tree in the memory until the current instance of javac is GCed.

I would like to ask you to:
-let checkForJsr311Bootstrap perform the cheapest tests first. In this case, all the checks in the second "if" seem cheaper to me than detecting whether there is a source for an Element.
-using org.netbeans.api.java.source.SourceUtils.getFile instead of Trees.getTree should be much cheaper - at least in cases Trees.getTree would actually parse a source. Please try to use it if at all possible. (Although not even this method is really cheap - please call it as few times as possible.)

Thanks.
Comment 1 Denis Anisimov 2011-12-13 09:36:54 UTC
web-main#46c1dec939f1
Comment 2 Quality Engineering 2011-12-14 12:09:42 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/46c1dec939f1
User: Denis Anisimov <ads@netbeans.org>
Log: Fix for BZ#206274 - org.netbeans.modules.websvc.rest.model.impl.Utils.checkForJsr311Bootstrap invokes Trees.getTree and some CDI analysis exension  (warnings).
Comment 3 Jan Lahoda 2012-01-25 09:19:21 UTC
The patch in:
websvc.restapi/src/org/netbeans/modules/websvc/rest/model/impl/Utils.java
seem fine to me - should ensure that the sources are not parsed in the given context.
Comment 4 Jiri Skrivanek 2012-02-17 14:53:55 UTC
Verified in repository.
http://hg.netbeans.org/releases/rev/36666d7c643e