Preface
When we use IntelliJ IDEA, we sometimes feel stuck. So how can we make IntelliJ IDEA better without upgrading the computer configuration?
We can optimize IntelliJ IDEA by modifying some settings of IntelliJ IDEA. Optimizing IntelliJ IDEA's performance can significantly improve development efficiency and reduce unnecessary waiting time
The following measures can be taken
- Make sure the IDEA version is up to date, as the JetBrains team continues to fix performance issues and introduce performance improvements in new releases.
-
Adjust memory allocation: By modification
File, increase IDEA's memory limit, for example
-Xmx2048m
and-Xms512m
Adjust to the value that suits your machine configuration. - Management plug-in: Disable or uninstall infrequently used plug-ins to reduce the startup time and memory usage of the IDE.
-
Optimize index settings: Reduce the number of indexed items, for example
Settings > Editor > General > Editor Tabs
Adjust the number of "Marking Occurrences". - Configure the build system: Make sure the build system is configured correctly, such as Gradle or Maven, and distributed using local build tools.
- Exclude unnecessary files: Configure exclusion rules so that IDEA does not index specific folders or file types.
- Code analysis on demand: Avoid frequent full-project analysis, manually trigger or perform smaller-range analysis.
-
Enable Smart Mode:pass
Settings > Appearance & Behavior > Appearance
Enable "Low Memory" mode to reduce rendering and animation effects. -
Optimize integration of external tools: Adjust the configuration of external tools, such as Git's
gc
set up . -
Enable hardware acceleration:exist
Settings > Appearance & Behavior > Appearance
Enable hardware acceleration to improve UI response speed. -
Avoid frequent full loading:use
File > Invalidate Caches / Restart...
Clear the cache and restart IDEA, but avoid frequent use. -
Performance monitoring:pass
Help > Edit Custom VM Options
Open the Performance Monitoring dialog box and adjust the JVM parameters to identify and resolve performance bottlenecks. -
Custom shortcut keys:pass
Settings > Keymap
Customize shortcut keys to reduce mouse operation and improve work efficiency. -
Avoid automatic import:exist
Settings > Editor > General > Auto Import
Disable automatic import in the process to reduce the burden of background processing. -
Restrict background tasks:exist
Settings > Appearance & Behavior > System Settings > Power Save Mode
Enable power saving mode in the background to restrict the tasks IDEA performs in the background. -
Use offline mode: When needed, pass
Help > Edit Custom VM Options
Enable offline mode to reduce network dependencies. - Code editing optimization: Turn off or adjust code editing functions, such as "Code Completion", "Live Templates", etc. to reduce resource consumption.
- Build configuration optimization: Configure different build settings for different development environments, such as using different JDK versions or build tools configuration.
- Avoid global search: Use limited scope searches instead of global searches to save resources.
- Regular maintenance: Carry out disk cleaning, database maintenance and index reconstruction to maintain IDEA's operating efficiency.
- Using an external editor: For large files, open with an external editor to avoid loading in IDEA.
-
Code warehouse optimization: Optimize Git or SVN settings, for example through
.git/config
Configuration files limit the loading of history. -
Restrict automatic updates:exist
Settings > Appearance & Behavior > System Settings > Updates
Adjust automatic update settings to reduce network and CPU burden. -
Adjust editor rendering:exist
Settings > Editor > Font
Adjust the font size and anti-aliasing settings to improve the rendering speed of the editor. - Using external build tools: For large build tasks, consider using external build tools such as the command line version of Maven or Gradle.
Parameter explanation of VM Options
IntelliJ IDEA's VM Options allows you to configure parameters of Java virtual machines at startup to control application behavior and performance.
These options are stored inIn the file, it is usually located in the installation directory of IntelliJ IDEA
bin
in folder.
Here are some commonly used VM Options parameters:
1. Memory settings
-
-Xms
: Sets the initial heap size of the Java virtual machine. For example,-Xms512m
Set the initial heap size to 512MB. -
-Xmx
: Set the maximum heap size of the Java virtual machine. For example,-Xmx2g
Set the maximum heap size to 2GB.
-Xms512m -Xmx2g
Increase-Xmx
Parameters can improve the performance of IntelliJ IDEA, especially when dealing with large projects.
2. Performance Tuning
-XX:ReservedCodeCacheSize
:
- Sets the size reserved for the code cache.
- By default, IDEA allocates a certain amount of space for the code cache, and you can increase this space size as needed to improve compilation performance.
-XX:ReservedCodeCacheSize=512m
-XX:MaxPermSize
(Deprecated):
- Used to set the maximum size of the permanent generation in earlier versions of Java.
- In Java 8 and later, the permanent generation has been replaced by metaspace.
3. GC (garbage recycling) optimization
-XX:+UseConcMarkSweepGC
and-XX:+UseParNewGC
: Enable parallel garbage collector, suitable for large memory and multi-core processors.
-XX:+UseConcMarkSweepGC -XX:+UseParNewGC
-XX:NewRatio
:
- Set the ratio of the new generation to the old generation.
- For example,
-XX:NewRatio=3
It means that the new generation takes up 1/4 of the heap space.
-XX:NewRatio=3
4. Debugging and Diagnosis
-
-XX:+HeapDumpOnOutOfMemoryError
: Automatically generate a heap dump file when memory overflows, which is used to analyze memory problems.
-XX:+HeapDumpOnOutOfMemoryError
-
-XX:HeapDumpPath
: Specifies the generation path of the heap dump file.
-XX:HeapDumpPath=/path/to/dump/directory
5. Other settings
-D
The parameters at the beginning can set system properties.
like-=UTF-8
Used to specify that the file is encoded as UTF-8.
-=UTF-8
6. Steps to set up VM Options
- Open IntelliJ IDEA.
- Click on the top menu
Help
->Edit Custom VM Options
。 - In the open file, edit or add the parameters you need.
- Save the file and restart IntelliJ IDEA to make the settings take effect.
By configuring these VM Options parameters properly, you can optimize the performance and behavior of IntelliJ IDEA, especially when handling large projects and complex operations to improve development efficiency and experience.
Summarize
Through the above measures, the performance of IntelliJ IDEA can be significantly improved and makes it more suitable for the development needs of large-scale projects.
The above is personal experience. I hope you can give you a reference and I hope you can support me more.