Is your JetBrains IDE turning into a memory hog? Try this simple fix

·

4 min read

Is your JetBrains IDE turning into a memory hog? Try this simple fix

Recent versions of JetBrains IDEs have been accused of insatiable memory consumption, leading to user frustration and unanswered support tickets. While the official solution remains elusive, I discovered a workaround that might just offer sweet relief: replacing the default bundledJetBrains runtime JBRJava 17 JDK withGraalVMJava 21 JDK.

The problem: Memory woes run amok

Many developers rely on JetBrains IDEs for their powerful features and smooth workflows. However, recent iterations have been plagued by high memory usage, often exceeding 4 GB and occasionally reaching a staggering 10 GB or even 20 GB. This can cripple OS performance, reduce productivity, and leave users exasperated. Note that changing the memory settings (Help -> Change Memory Settings) won’t help because this is a problem with JetBrains native memory usage.

Unanswered pleas: Frustration mounts

Despite user complaints and support tickets, JetBrains hasn’t yet provided a definitive solution. This leaves developers searching for alternatives, impacting their productivity and satisfaction.

The workaround emerges: GraalVM to the rescue!

My experimentation revealed a promising workaround: switching from the default bundled JetBrains runtime JBR Java 17 JDK to an alternative, more recent JDK like OpenJDK and GraalVM. These virtual machines boast significant memory savings, leading to:

  • 50–75% reduction in memory usage with GraalVM Java 21 JDK.

  • 30% reduction with OpenJDK, Eclipse Temurin and JetBrains runtime JBR (vanilla) Java 21 JDK. While not as dramatic as GraalVM, OpenJDK and Eclipse Temurin offer some memory relief and high Java application compatibility, making it a viable option.

The moment of truth: Replace the boot JDK

First, you need to have an alternative JDK installed. I recommend using GraalVM for maximum performance and Eclipse Temurin or OpenJDK for best compatibility.

On Windows with Chocolatey package manager

Run this command in the Command Prompt: choco install graalvm

The JDK will be installed in C:\Program Files\GraalVM\graalvm-community-openjdk-<version>.

On Windows without a package manager

Follow the official instructions here: https://www.graalvm.org/latest/docs/getting-started/windows/

On macOS

We cannot use GraalVM or other custom JDKs as JetBrains on macOS requires the installed Java JDK to have a macOS application layout. Fortunately, using a vanilla version of JetBrains runtime JBR Java 21 JDK could still achieve a 25–30% memory usage reduction.

Now, open a project in your JetBrains IDE, and double-tap the Shift key to bring up the search dialogue.

Type “boot java” and click “Choose Boot Java Runtime for the IDE…”

Click “Add Custom Runtime…” and add or select an alternative JDK. To choose a vanilla JetBrains runtime JBR, scroll to the bottom of the list. Click OK and restart your IDE.

Test results: Instant 50% memory consumption reduction

Using the default JetBrains runtime JBR Java 17 JDK — 2.76 GB memory consumption:

Using the default JetBrains runtime JBR Java 17 JDK — 2.76 GB memory consumption

Using an alternative Java 21 JDK — 1.34 GB memory consumption:

Beyond numbers: What it means for you

This simple switch can translate to real-world benefits:

  • Improved performance: Say goodbye to slowdowns and lags caused by memory exhaustion.

  • Enhanced productivity: Work efficiently without resource constraints hindering your workflow.

  • Peace of mind: Ditch the frustration of excessive memory usage and focus on coding magic.

Noteworthy caveats

Before rushing to replace your JDK, keep a few things in mind:

  • Compatibility: Ensure your specific IDE version and plugins are compatible with GraalVM. For instance, the new JetBrains IDE UI doesn’t work well due to the lack of JCEF support and it won't allow you to preview markdown files.

  • Testing: Conduct thorough testing to ensure everything works as expected before adopting this workaround permanently.

  • Sharing and feedback: Let JetBrains know about your experience, as community feedback can influence future development decisions.

Conclusion

While a permanent fix from JetBrains is still awaited, this GraalVM workaround offers a glimmer of hope for developers struggling with memory-hungry IDEs. By sharing your experience and encouraging others to do the same, you can contribute to finding a more widespread solution in the future.

Remember, knowledge is power! Spread the word, experiment, and reclaim your development environment from the clutches of memory overload.