Java 如何提高 Netbeans 的性能?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/229763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 11:46:20  来源:igfitidea点击:

How to improve Netbeans performance?

javaperformancejakarta-eenetbeans

提问by yeradis

Is there a real way to get Netbeans to load and work faster?

有没有真正的方法可以让 Netbeans 加载和工作得更快?

It is too slow and gets worse when you have been coding for some time. It eats all my RAM.

当您编码一段时间时,它太慢并且变得更糟。它吃掉了我所有的内存。



I am on a Windows machine, specifically Windows Server 2008 Datacenter Edition x64, 4Gb of RAM, 3Ghz Core 2 Duo processor, etc. I am using the x64 JDK. I use the NOD32 Antivirus since for me it is the best in machine performance.

我在 Windows 机器上,特别是 Windows Server 2008 Datacenter Edition x64、4Gb 内存、3Ghz Core 2 Duo 处理器等。我使用的是 x64 JDK。我使用 NOD32 Antivirus,因为对我来说它是最好的机器性能。

In Task Manager netbeans.exe only shows no more than 20 Mb, java.exe more than 600Mb.

在任务管理器中 netbeans.exe 只显示不超过 20 Mb,java.exe 超过 600Mb。

My project is a J2EE web application, more than 500 classes, only the project libraries not included (externals). And when I said slow, I mean 3, 4, 5 minutes or more Netbeans is frozen.

我的项目是一个 J2EE web 应用程序,有 500 多个类,只有项目库没有包含(外部)。当我说慢时,我的意思是 3、4、5 分钟或更长时间的 Netbeans 被冻结。

Is my project just too large for Netbeans, if it has to read all files to get the state of files like error warnings, svn status and more? Can I disable all this? Is it possible to set it to scan only when I open a file?

我的项目对于 Netbeans 来说是不是太大了,如果它必须读取所有文件才能获取错误警告、svn 状态等文件的状态?我可以禁用所有这些吗?是否可以将其设置为仅在打开文件时进行扫描?

My CPU use is normally at 30 percent with all my tools opened, I mean Netbeans, MS SQL Manager, Notepad, XMLSpy, Task Manager, Delphi, VirtualBox. Netbeans eats more RAM than my virtualized systems.

我的 CPU 使用率在所有工具打开时通常为 30%,我的意思是 Netbeans、MS SQL 管理器、记事本、XMLSpy、任务管理器、Delphi、VirtualBox。Netbeans 比我的虚拟化系统占用更多 RAM。

In Linux it is as slow as in Windows in the same machine (Ubuntu 8.04 x64).

在 Linux 中,它与同一台机器上的 Windows 一样慢(Ubuntu 8.04 x64)。

It is true that the Netbeans team improved startup speed but when it opens it begins to cache ALL.

Netbeans 团队确实提高了启动速度,但是当它打开时它开始缓存 ALL。

I have used some JVM parameters to set high memory usage and others: "C:\Program Files\NetBeans Dev\bin\netbeans.exe" -J-Xms32m -J-Xmx512m -J-Xverify:none -J-XX:+CMSClassUnloadingEnabled

我使用了一些 JVM 参数来设置高内存使用率和其他参数: "C:\Program Files\NetBeans Dev\bin\netbeans.exe" -J-Xms32m -J-Xmx512m -J-Xverify:none -J-XX:+CMSClassUnloadingEnabled

But it is still slow.

但它仍然很慢。

回答by Joshua

  • Download the latest Netbeans
  • Remove all the plugins you don't need.
  • Use the latest version of Java
  • 下载最新的 Netbeans
  • 删除所有不需要的插件。
  • 使用最新版本的 Java

回答by devstopfix

Is it a corporate Windows machine? If so aggressive virus scanners can really slow down modern IDEs. Check your task manager for processes that are using a lot of CPU or disk reads.

它是企业 Windows 机器吗?如果如此激进的病毒扫描程序真的可以减慢现代 IDE 的速度。检查您的任务管理器是否有使用大量 CPU 或磁盘读取的进程。

回答by James Schek

Also defragment your disk. Netbeans is very aggressive about creating caches of one form or another. Most of them get persisted to disk at some point or another which can affect startup time. Virus scanners (Symantec in particular), Desktop search engines, and any other intrusive I/O product can drastically reduce performance.

还要对磁盘进行碎片整理。Netbeans 非常积极地创建一种或另一种形式的缓存。它们中的大多数会在某个时间点被持久化到磁盘,这会影响启动时间。病毒扫描程序(尤其是赛门铁克)、桌面搜索引擎和任何其他侵入性 I/O 产品都可以大大降低性能。

I have noticed that Netbeans can be tempermental at times and its performance can vary greatly between two machines with nearly identical specs. My work machine has terrible performance and is unusable at times, but it's lightning fast when I use it on my home machine (with bigger projects in many cases).

我注意到 Netbeans 有时会很不稳定,它的性能在规格几乎相同的两台机器之间差异很大。我的工作机器性能很差,有时无法使用,但是当我在家用机器上使用它时(在许多情况下有更大的项目),它的速度非常快。

回答by Fortyrunner

If its on a corporate machine - make sure that the caches aren't stored on the network

如果它在公司机器上 - 确保缓存没有存储在网络上

回答by James Tikalsky

Everyone should note that Sun's Java Virtual Machine for Windows does not use shared memory. This means that the more heap you give to your VM, the more memory it keeps to itself. The advantage of more heap is less garbage-collection, and perhaps faster performance of the Java application you're running, but the downside is that your other applications may have less memory to work with, and your system may feel slower due to this.

大家应该注意,Sun 的 Java 虚拟机 for Windows 不使用共享内存。这意味着您给 VM 的堆越多,它保留给自己的内存就越多。更多堆的优点是垃圾收集更少,并且您正在运行的 Java 应用程序的性能可能会更快,但缺点是您的其他应用程序可能使用的内存更少,因此您的系统可能会因此而感觉更慢。

回答by schmunk

A more or less detailed description, why NetBeans if slow so often can be found in the article:

可以在文章中找到或多或少详细的描述,为什么 NetBeans 如此频繁地运行缓慢:

Boost your NetBeans performance

First. check what NetBeans is actually doing on your disk. On a Mac you can issue this command:

  sudo fs_usage | grep /path/to/workspace

In my special case I got a directory which didn't exist any longer, but NetBeans tries to access the folder all the time:

  14:08:05 getattrlist /path/to/workspaces/pii 0.000011 java

Repeated many, many, many times. If you have a similar problem, fix it by deleting your NetBeans cache folder here:

   ~/.netbeans/6.8/var/cache

If your NetBeans.app is still making a lot of disk I/O. Check if it's accessing the subverison folders and svncache.

I had to disable the subversion features with config file:

  ~/.netbeans/VERSION/config/Preferences/org/netbeans/modules/versioning.properties 

add a line:

  unversionedFolders=FULL_PATH_TO_PROJECT_FOLDER  

SOURCE: Netbeans forums

提高您的 NetBeans 性能

第一的。检查 NetBeans 在您的磁盘上实际执行的操作。在 Mac 上,您可以发出以下命令:

  sudo fs_usage | grep /path/to/workspace

在我的特殊情况下,我得到了一个不再存在的目录,但 NetBeans 一直尝试访问该文件夹:

  14:08:05 getattrlist /path/to/workspaces/pii 0.000011 java

重复了很多很多很多次。如果您遇到类似问题,请在此处删除您的 NetBeans 缓存文件夹来修复它:

   ~/.netbeans/6.8/var/cache

如果您的 NetBeans.app 仍在进行大量磁盘 I/O。检查它是否正在访问 subverison 文件夹和 svncache。

我不得不使用配置文件禁用颠覆功能:

  ~/.netbeans/VERSION/config/Preferences/org/netbeans/modules/versioning.properties 

添加一行:

  unversionedFolders=FULL_PATH_TO_PROJECT_FOLDER  

来源:Netbeans 论坛

IMHO it's mainly related to a lot of disk I/O caused by missing files or folders and svncache.

恕我直言,这主要与丢失文件或文件夹和 svncache 导致的大量磁盘 I/O 有关。

回答by ismail

I had the same problem with Netbeans being so slow, but it is now much better after deactivating the SVN plug-in. I think that may help.

我遇到了同样的问题,Netbeans 太慢了,但在停用 SVN 插件后现在好多了。我认为这可能会有所帮助。

Good luck

祝你好运

回答by atamanroman

Don't invest time in optimizing your NB installation as long as you can scale vertically: get a SSD (and faster hardware in general).

只要您可以垂直扩展,就不要花时间优化您的 NB 安装:获得 SSD(以及一般更快的硬件)。

Also:

还:

  • Add an exception for all relevant folders (e.g. project dir, temp dir) to your anti virus software (or better, get rid of it).
  • Don't use network drives for your projects
    • check if your home drive is local
    • check if your IDE uses non-local folders (e.g. %AppData%)
  • 将所有相关文件夹(例如项目目录、临时目录)的例外添加到您的防病毒软件中(或者更好地将其删除)。
  • 不要为您的项目使用网络驱动器
    • 检查您的主驱动器是否在本地
    • 检查您的 IDE 是否使用非本地文件夹(例如%AppData%

回答by Kdeveloper

In order to improve Netbeans startup and build times one should (in this order):

为了改善 Netbeans 启动和构建时间,您应该(按此顺序):

  1. Make sure that one has enough free RAMmemory (4GB Windows is enough on my 64-bit system)
  2. Buy an SSD, it makes all the difference in startup time and build time (my project build time wend from 60 seconds to 6 seconds!)
  3. Watch out for the virus scanner, they can slow down random file access considerably (make sure they don't scan your .java and .class files!)
  4. Buy the fastest processoryou can get your hands on.
  1. 确保一个有足够的空闲RAM内存(4GB Windows 在我的 64 位系统上就足够了)
  2. 购买SSD,它在启动时间和构建时间上都有所不同(我的项目构建时间从 60 秒缩短到 6 秒!)
  3. 注意病毒扫描程序,它们会大大减慢随机文件访问的速度(确保它们不会扫描您的 .java 和 .class 文件!)
  4. 购买速度最快的处理器

回答by Ravish

Very simple solution to the problem when your NetBeansor EclipseIDE seems to be using too much memory:

当您的NetBeansEclipseIDE 似乎使用太多内存时,非常简单的问题解决方案:

  1. Disable the plugins you are not using.
  2. close the projects you are not working on.
  1. 禁用您不使用的插件。
  2. 关闭您不从事的项目。

I was facing similar problem with Netbeans 7.0 on my Linux Mint as well Ubuntu box. Netbeans was using > 700 MiB space and 50-80% CPU. Then I decided do some clean up. I had 30 plugins installed, and I was not using most of them. So, I disabled the plugins I was not using, a whopping 19 plug ins I disabled. now memory uses down to 400+ MiB and CPU uses down to 10 and at max to 50%.

我的 Linux Mint 和 Ubuntu 机器上的 Netbeans 7.0 也遇到了类似的问题。Netbeans 使用了 > 700 MiB 的空间和 50-80% 的 CPU。然后我决定做一些清理。我安装了 30 个插件,但我没有使用其中的大部分。所以,我禁用了我没有使用的插件,我禁用了多达 19 个插件。现在内存使用低至 400+ MiB,CPU 使用低至 10,最多 50%。

Now my life is much easier.

现在我的生活轻松多了。