From the main menu, select Help | Change Memory Settings.
Set the necessary amount of memory that you want to allocate and click Save and Restart.
This changes the value of the -Xmx option used by the JVM and restarts IntelliJ IDEA with the new setting.
The Change Memory Settings action is available starting from IntelliJ IDEA version 2019.2. For previous versions, you can change the value of the -Xmx option manually as described in JVM options.