IntelliJ IDEA
IDE memory limit
Mac OS
Software Configuration
Programming Tools

How to increase IDE memory limit in IntelliJ IDEA on Mac?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

To increase IntelliJ IDEA's memory limit on Mac, open the IDE, go to Help > Edit Custom VM Options, and change the -Xmx line to a higher value such as -Xmx4096m or -Xmx4g. Save the file and restart IntelliJ. The change takes effect on next launch.

This is the most common fix for sluggish performance, frequent garbage collection pauses, and OutOfMemoryError exceptions when working with large projects. IntelliJ ships with a default heap size of 2048 MB (as of 2024+ versions), which is sufficient for most projects but can be exhausted by monorepos, large codebases with many modules, or heavy plugin usage.

Understanding JVM Memory in IntelliJ

IntelliJ IDEA runs on the JVM, and its memory is governed by JVM startup flags. The most important ones for performance are:

FlagPurposeDefault (2024+)
-XmxMaximum heap size2048m
-XmsInitial heap size128m
-XX:ReservedCodeCacheSizeJIT compiler cache512m
-XX:+UseG1GCGarbage collector selectionEnabled
-XX:SoftRefLRUPolicyMSPerMBSoft reference retention50

The heap (-Xmx) is where IntelliJ stores parsed code models, indexes, caches, and runtime objects. When the heap fills up, the garbage collector runs more frequently, causing UI freezes. If it still cannot free enough memory, you get an OutOfMemoryError.

This is the official and most reliable method.

Step 1: Open IntelliJ IDEA.

Step 2: Navigate to Help > Edit Custom VM Options on the menu bar.

If this is your first time, IntelliJ will prompt you to create the file. Click "Create" to proceed.

Step 3: The file opens in the editor. It is located at:

 
~/Library/Application Support/JetBrains/IntelliJIdea2024.3/idea.vmoptions

The path varies by IntelliJ version. The year and version number in the directory name match your installed version.

Step 4: Find the -Xmx line and increase it:

 
1# Before
2-Xmx2048m
3
4# After
5-Xmx4096m

A complete VM options file for a developer working with large projects might look like:

 
1-Xms512m
2-Xmx4096m
3-XX:ReservedCodeCacheSize=1024m
4-XX:+UseG1GC
5-XX:SoftRefLRUPolicyMSPerMB=50
6-XX:CICompilerCount=2
7-XX:+HeapDumpOnOutOfMemoryError
8-XX:-OmitStackTraceInFastThrow

Step 5: Save the file and restart IntelliJ IDEA. The new memory limits take effect on the next launch.

Method 2: Memory Settings Action

IntelliJ 2021.2 and later provides a built-in dialog for changing memory settings without editing the VM options file directly.

Step 1: Press Shift twice to open "Search Everywhere."

Step 2: Type "Change Memory Settings" and select the action.

Step 3: A dialog appears with a slider. Set the desired maximum heap size and click "Save and Restart."

This method modifies the same idea.vmoptions file but provides a simpler interface for users who only need to change -Xmx.

Method 3: Edit the File Directly in Terminal

If IntelliJ is not launching (perhaps due to an OutOfMemoryError during startup), you can edit the VM options file directly from the terminal:

bash
1# Find your IntelliJ config directory
2ls ~/Library/Application\ Support/JetBrains/
3
4# Edit the VM options file (adjust the version directory)
5nano ~/Library/Application\ Support/JetBrains/IntelliJIdea2024.3/idea.vmoptions

Change the -Xmx value, save, and relaunch IntelliJ.

If the file does not exist yet, create it. IntelliJ merges your custom file with its built-in defaults:

bash
1cat > ~/Library/Application\ Support/JetBrains/IntelliJIdea2024.3/idea.vmoptions << 'EOF'
2-Xms512m
3-Xmx4096m
4-XX:ReservedCodeCacheSize=1024m
5-XX:+UseG1GC
6-XX:SoftRefLRUPolicyMSPerMB=50
7-XX:+HeapDumpOnOutOfMemoryError
8EOF

How Much Memory to Allocate

The right value depends on your project size and available system RAM:

System RAMSuggested -XmxNotes
8 GB2048m-3072mLeave room for OS and browser
16 GB4096mGood for most large projects
32 GB6144m-8192mMonorepos, multiple languages
64 GB+8192m-12288mExtreme cases only

As a rule of thumb, allocate no more than 25-35% of your total system RAM to IntelliJ. The OS, browser, Docker, local servers, and other tools all compete for memory. Over-allocating to IntelliJ can cause the OS to swap other processes to disk, making the entire system slow.

Verifying the Change

After restarting, verify that IntelliJ is using the new memory limit:

Memory Indicator: Enable the memory indicator in the status bar. Go to Settings > Appearance & Behavior > Appearance and check "Show memory indicator." The bottom-right corner will show current usage vs. maximum heap.

About Dialog: Go to Help > About. The dialog shows the JVM version and configured memory.

Diagnostic Tools: Go to Help > Diagnostic Tools > Activity Monitor to see real-time memory usage broken down by subsystem.

Beyond Heap Size: Other Performance Tuning

Increasing -Xmx solves heap exhaustion, but other settings affect IDE responsiveness:

Code Cache Size

The JIT compiler stores compiled methods in the code cache. If it fills up, the compiler stops optimizing, and the IDE gradually slows down:

 
-XX:ReservedCodeCacheSize=1024m

The default of 512m is usually sufficient, but increase it if you see "CodeCache is full" warnings in the idea.log file.

Garbage Collection Tuning

IntelliJ uses G1GC by default, which is a good general-purpose collector. For very large heaps (8 GB+), ZGC can reduce pause times:

 
-XX:+UseZGC

ZGC keeps GC pauses under 10ms regardless of heap size, which eliminates the periodic freezes that G1GC can cause with large heaps. It requires JDK 15+ (IntelliJ bundles a compatible JDK).

Soft Reference Policy

IntelliJ uses soft references for caches. The SoftRefLRUPolicyMSPerMB setting controls how aggressively the GC reclaims soft references:

 
-XX:SoftRefLRUPolicyMSPerMB=50

Lower values mean caches are freed sooner, which reduces memory pressure but increases cache misses (more re-parsing, re-indexing). The default of 50 is a good balance.

Reducing Memory Usage Without Increasing Limits

If you cannot allocate more memory, these steps reduce IntelliJ's footprint:

  • Disable unused plugins: Settings > Plugins. Disable everything you do not actively use.
  • Exclude directories from indexing: Right-click a directory > Mark Directory As > Excluded. Build output, node_modules, and generated code are common candidates.
  • Reduce inspections: Settings > Editor > Inspections. Disable inspection profiles for languages you are not using in the current project.
  • Close unused projects: Each open project consumes heap. Use one project per window when memory is tight.
  • Invalidate caches: File > Invalidate Caches. This clears index corruption that can cause excessive memory usage.

Common Pitfalls

  • Editing the wrong VM options file. IntelliJ has a bundled idea.vmoptions inside the .app bundle and a user-level file in ~/Library/Application Support/JetBrains/. Always use the user-level file (via Help > Edit Custom VM Options) so your changes survive IDE updates.
  • Setting -Xmx too high and starving the OS. If IntelliJ uses 12 GB on a 16 GB machine, the OS swaps aggressively and everything slows down. Keep -Xmx under 35% of system RAM.
  • Setting -Xms equal to -Xmx. This pre-allocates the full heap on launch, which wastes memory when the IDE is idle. Let the heap grow on demand.
  • Forgetting to restart after changing VM options. The JVM reads these flags at startup. Changes take effect only after a full restart (not just closing and reopening a project).
  • Ignoring the "Memory" indicator. Enable it and monitor usage. If you see the heap hitting -Xmx frequently followed by GC drops, the heap is too small. If it rarely exceeds 50% of -Xmx, you have allocated too much.

Summary

  • Increase IntelliJ's memory by editing Help > Edit Custom VM Options and setting -Xmx to a higher value. 4096m works well for most large projects.
  • The VM options file is at ~/Library/Application Support/JetBrains/IntelliJIdea{version}/idea.vmoptions.
  • Do not allocate more than 25-35% of system RAM to IntelliJ.
  • Enable the memory indicator to monitor real-time heap usage.
  • Consider code cache size (-XX:ReservedCodeCacheSize) and garbage collector selection (-XX:+UseZGC for large heaps) alongside heap size.
  • Reduce memory demand by disabling unused plugins, excluding directories from indexing, and closing unused projects.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions