PyCharm does not start after setting the ReservedCodeCacheSize to too big value

Answered

Hello,

On MacOS, the PyCharm Professional IDE does not start and does not show any error popup after a user sets the `ReservedCodeCacheSize` setting to a too big value like 4096M. The user may set this setting to such value when the IDE shows a popup to increase memory for the JVM used by the IDE. This popup showed for me after opening a too big JSON file which (I assume) triggered the out of memory handler in the IDE.

(I don't know if this issue can happen on other Jetbrains IDEs or systems but I guess it is very likely that it does; also while I doubt it matters, my PyCharm was installed via Jetbrains Toolbox).

I noticed the issue only after restarting the PyCharm after few days and I found its cause by launching the IDE from the command line. Below you can see the logs from my PyCharm execution:

$ ./pycharm
2022-05-16 13:32:51.738 pycharm[2435:24511] allVms required 1.8*,1.8+
2022-05-16 13:32:51.738 pycharm[2435:24511] Found Java Virtual Machines:
2022-05-16 13:32:51.739 pycharm[2435:24511] /Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app/Contents/jbr
2022-05-16 13:32:51.739 pycharm[2435:24511] Required VMs: 1.8*,1.8+
2022-05-16 13:32:51.739 pycharm[2435:24511] Chosen VM:
2022-05-16 13:32:51.739 pycharm[2435:24511] /Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app/Contents/jbr
2022-05-16 13:32:51.740 pycharm[2435:24514] Current Directory: /Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app/Contents/MacOS
2022-05-16 13:32:51.740 pycharm[2435:24514] parseVMOptions: PYCHARM_VM_OPTIONS = (null)
2022-05-16 13:32:51.740 pycharm[2435:24514] fullFileName is: /Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app/Contents/bin/pycharm.vmoptions
2022-05-16 13:32:51.740 pycharm[2435:24514] fullFileName exists: /Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app/Contents/bin/pycharm.vmoptions
2022-05-16 13:32:51.740 pycharm[2435:24514] parseVMOptions: /Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app/Contents/bin/pycharm.vmoptions
2022-05-16 13:32:51.740 pycharm[2435:24514] Reading at /Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app/Contents/bin/pycharm.vmoptions OK
2022-05-16 13:32:51.745 pycharm[2435:24514] parseVMOptions: /Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app.vmoptions
2022-05-16 13:32:51.745 pycharm[2435:24514] Reading at /Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app.vmoptions OK
2022-05-16 13:32:51.745 pycharm[2435:24514] parseVMOptions: platform=17 user=18 file=/Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app.vmoptions
Invalid ReservedCodeCacheSize=4096M. Must be at most 2048M.
Invalid ReservedCodeCacheSize=4096M. Must be at most 2048M.
2022-05-16 13:32:51.755 pycharm[2435:24514] JNI_CreateJavaVM (/Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app/Contents/jbr) failed: -1

I was able to fix this issue by modifying the config file PyCharm uses for its JVM options, which is listed in the logs: /Users/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5591.52/PyCharm.app.vmoptions and changing the following line:

-XX:ReservedCodeCacheSize=4096m

To:

-XX:ReservedCodeCacheSize=2048m

 

While I was able to resolve the issue myself, I am sending this post with hope that this nuance will be fixed and that IDE users will not have to spend time on debugging the tool they want to use :).

0
3 comments

PyCharm Professional IDE does not start and does not show any error popup after a user sets the `ReservedCodeCacheSize` setting to a too big value like 4096M

Because it is not supposed to be set to such a big value. Default value for ReservedCodeCacheSize is set to 240m when the IDE is installed (512m in the latest versions).

The user may set this setting to such value when the IDE shows a popup to increase memory for the JVM used by the IDE

Best course of action in such a case is to first increase the -Xmx value via Help | Change Memory Settings. If it doesn't help, it is best to contact JetBrains Support for further instructions.

Users may alter other VM settings, but it is not recommended and may lead to various problems.

0

Because it is not supposed to be set to such a big value. Default value for ReservedCodeCacheSize is set to 240m when the IDE is installed (512m in the latest versions).

And yet, the IDE allows to set an invalid value in a popup that appears during an OOM situation.

The point of this post is that the IDE should have a better user experience. Either the IDE should not allow the user to set invalid values in its UI or the IDE launcher should validate and propose an autofix (?) of those beforehand.

0

What popup are you referring to exactly? Is it the this one?

0

Please sign in to leave a comment.