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 269095 - "Background scanning of projects" hangs EDT thread
Summary: "Background scanning of projects" hangs EDT thread
Status: REOPENED
Alias: None
Product: editor
Classification: Unclassified
Component: Parsing & Indexing (show other bugs)
Version: 8.2
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: ebakke
URL:
Keywords:
: 243483 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-11-23 18:48 UTC by ebakke
Modified: 2017-05-31 18:15 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Profiling session showing repeatedly hung EDT thread during background scanning of projects and otherwise idle editor (1.01 MB, application/octet-stream)
2016-11-23 18:48 UTC, ebakke
Details
Call stack graph showing repeatedly hung IDE (from attached profiling session) (22.82 KB, image/png)
2016-11-23 18:57 UTC, ebakke
Details
.npss file attached from NetBeans (289.59 KB, application/x-npss)
2016-12-15 20:51 UTC, ebakke
Details
messages.log file for NetBeans session during EDT hang during indexing (505.66 KB, text/plain)
2016-12-15 20:56 UTC, ebakke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ebakke 2016-11-23 18:48:03 UTC
Created attachment 163008 [details]
Profiling session showing repeatedly hung EDT thread during background scanning of projects and otherwise idle editor

The "Background scanning of projects" hangs the EDT thread, making the IDE completely unusable. Every 3.75 seconds on average the UI responds again for a very brief time (<1 sec) before becoming unresponsive again for another 3.75 seconds. This repeats over and over again until the scanning process is over.

The attached profiling snapshot was recorded while project scanning was happening after opening the "refactoring.java" module in the NetBeans IDE source code. During this snapshot the IDE is being left idle with the cursor blinking in an open Java editor and the "Background scanning of projects" ongoing (with its progress bar showing in the toolbar). The hung EDT thread can be clearly seen from the call stack graph.
Comment 1 ebakke 2016-11-23 18:51:04 UTC
Related bugs:
https://netbeans.org/bugzilla/show_bug.cgi?id=228822 (relating to save action--closed incomplete)
https://netbeans.org/bugzilla/show_bug.cgi?id=243483 (relating to save action--but seems to be the same problem)
Comment 2 Jiri Kovalsky 2016-11-23 18:52:53 UTC
Reassigning for further evaluation.
Comment 3 ebakke 2016-11-23 18:53:21 UTC
*** Bug 243483 has been marked as a duplicate of this bug. ***
Comment 4 ebakke 2016-11-23 18:57:54 UTC
Created attachment 163009 [details]
Call stack graph showing repeatedly hung IDE (from attached profiling session)
Comment 5 Tomas Hurka 2016-11-24 09:54:29 UTC
This issue has nothing to do with profiler.

Thanks for self-sampler snapshot. 
The snapshot shows that the problem seems to be caused by excessive GC. Please
try to reproduce it once more and attach new self-sampler snapshot and
messages.log file from the same IDE run. 
Thanks.
Comment 6 ebakke 2016-12-15 20:51:21 UTC
Created attachment 163253 [details]
.npss file attached from NetBeans

.npss file
Comment 7 ebakke 2016-12-15 20:56:29 UTC
Created attachment 163254 [details]
messages.log file for NetBeans session during EDT hang during indexing

As requested, I've uploaded a new snapshot and messages.log file during a hang.

This time, the same hang was triggered by adding a method in a Java file (an abstract superclass of several other classes) and saving the changes, causing reindexing.
Comment 8 ebakke 2017-05-31 18:15:01 UTC
After observing this bug and earlier variations of it for four years (first reported as #228822), I have finally figured it out.

The problem is that the launcher script used in the MacOS distribution of NetBeans caps the heap size at 1GB, regardless of the amount of memory available on the user's computer. This can be seen in the "heap_size" method in the "Contents/MacOS/netbeans" script in the NetBeans application bundle:

-----
if [ $mem -gt 1024 ] ; then
  mem=1024
-----

Manually setting -J-Xmx3072M in netbeans.conf makes the problem go away. Before setting this, I observed hangs almost daily (requiring an IDE restart)--but now, for the last two months, I have never observed the problem. The fact that the IDE runs for weeks without problems suggests the problem was simply a heap size issue, rather than a memory leak.

I suggest changing the maximum heap size policy in the netbeans startup script. Maybe set the maximum heap size to half or a third of the available memory rather than a fifth, and eliminate the 1GB cap?