-->

Eclipse hangs on copy/cut for JavaScript files

2019-02-02 03:42发布

问题:

I have Eclipse Kepler and NodeEclipse plugin installed. For NodeEclipse's performance reasons I have disabled content assistant for JavaScript files.

Problem: Whenever I copy or cut some lines in JS files (ctrl+c / ctrl+x), the CPU usages goes 100% and the eclipse process eats up all memory (>1GB). I think some GC thrashing is happening. Increasing JVM max memory more is an option, but isn't 1GB enough for eclipse?

This could be some memory leak. Is this specific problem with Nodeclipse? Are there any workarounds/settings in eclipse to diable?

Edited: When I double click a variable, CPU pumps to 100% for 3-4 seconds, comes down. I have mark occurences already disbled. This is happending only for route/*.js files and not for public folder. Investigating more, I find that commenting line containing require('<package-name>') solves this problem, why?

回答1:

found the solution:

go to Window>Preferences>JavaScript>Editor>Mark Occurrences and unselect the checkboxes. That should do it.

Reason for this problem:

When u press ctrl for copy/paste, it assumes that is a "ctrl+mouseOver" operation, that we do before clicking on a method/variable name to reach its declaration point, or access its documentation. Hence, it tries to find all the occurrences of the text currently under the mouse cursor, along with its declaration point and documentation.

Hope this helps :)



回答2:

Navigate to Window -> Preferences -> JavaScript -> Editor -> Typing -> When pasting

then uncheck Update imports.

Performance improved tremendously in my case. Hat tip to the comment left by @Alexander Taylor.



回答3:

This is first Nodeclipse performance related issue I hear.

I think memory usage limits are to insure that bad routines don't eat memory without stop (and affecting all operating system performance). Usually eclipse takes 200-400MB. If your eclipse average is above 500MB I guess you installed too many plugins into 1 Eclipse instance.

Raise an issue for Nodeclipse developers https://github.com/Nodeclipse/nodeclipse-1/ and give exact OS, Java, Eclipse, Nodeclipse versions. Also because it is performance issue you should give your PC configuration CPU, RAM size. Without that exact information it is impossible to investigate. You can also try yourself on other PC, other Eclipse version, other Java version etc and compare, find best combination. Please raise an issue even if you discovered solution yourself.

Read http://www.nodeclipse.org/ carefully. (You should have read before using for at least to learn some tips, and how to get help.) I am not sure it is Nodeclipse issue, but if it is reproduce-able, then it is to be solved quick or Eclipse bugzilla bug to be raise if it is some Eclipse project related.

For information (as of Nodeclipse 0.10)
1) Nodeclipse has 2 Editors: JSDT-based and TextEditor-based. Both have code completion. Trying TextEditor-based can tell if the issue is JSDT related.
2) For validation JSHint validation is used. JSHint is run on Rhino engine that is not so quick, and potentially can take time on large projects. However JSHint Integration is quite mature project and there are options to stop validation after certain number of warnings.



回答4:

Also if your .js file is huge, like 10000+ lines that maybe the cause. See old Eclipse is hanged on copy/paste in JavaScript files