ulimit -n shows different values in mac terminal and intellij terminal

I have tried increasing the max open files limit in mac by running the following command

sudo launchctl limit maxfiles 524288 10485760

When I try running ulimit -n it shows 524288

But while running the same command in IntelliJ idea's terminal it shows 10240

  1. I've tried reinstalling IntelliJ idea
  2. I've tried restarting IntelliJ after invalidating cache and restarting
  3. I've restarted the system multiple times.

Please let me know how to fix this issue.


Solution 1:

The problem is caused by IntelliJ being a Java program that is subject to the constraints of the Java virtual machine, which by default on macOS is set to limit the number of open files to 10240 - no matter which setting is used elsewhere in the operating system.

The solution is as follows:

  1. Add -XX:-MaxFDLimit in IntelliJ Idea (Help->Edit Custom VM options)
  2. Invalidate cache and restart IntelliJ

This removes the arbitrary 10240 limit on the Java virtual machine, and makes it so that IntelliJ is instead only limited by the general macOS open files limit - like any other program.