Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: OutOfMemoryError: PermGen space  (Read 2731 times)

Mira Lendin

  • Captain
  • ****
  • Posts: 315
    • View Profile
OutOfMemoryError: PermGen space
« on: July 05, 2022, 07:15:26 PM »

I am putting this here to help anyone getting this error "[Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.OutOfMemoryError: PermGen space"
If you run too many mods, odds are you have the same mod with memory leak as me which i couldn't single-out, It will cause you to crash every ~15-20 mins consistently.
1- Open your game folder
2- Right click on VMparams and select "edit with notepad" or any other text editor
3- Add the following line after "java.exe": "-XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled" make sure there is 1 and only 1 space before and after the added text.
This will force the engine to clear classes that are "no longer in use" and limit the size allocated to them preventing PemGen from leaking into memory space allocated for the game.
« Last Edit: July 05, 2022, 11:15:15 PM by Mira Lendin »
Logged
^^

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: OutOfMemoryError: PermGen space
« Reply #1 on: July 07, 2022, 02:47:12 AM »

this isn't a specific mod problem, it's a general problem w/ java 7's default garbage collection algorithm.

you can fix it (and post-battle slowdown) more reliably by updating to java 8.

jre8 installation guide from wisp in the discord (wispborne here on the forums)

Mini-guide: Switching to Java 8 to prevent the post-battle slowdown
Not officially supported, may cause unrelated issues, do at your own risk and please report back if you do notice it causing problems.

Symptoms
- After some time playing and immediately after a battle, the game FPS will plummet (eg from 60 to 15-25) and usually only go back to normal after a game restart.
- Saving/loading takes 5x longer than usual.
- Using at least one mod (that adds new sprites? incl. GraphicsLib).

Fix (slow down and read this part carefully)
1. Go to your starsector install and rename the jre folder to jre7.
2. Download either of the following (both are the same JRE 8 v271) (Mac/Linux users look below for download link):
    - (72 MB .zip) https://drive.google.com/file/d/1CGRtnv5hIGCtcdlvZXFO0F58VXqYUo6x/view?usp=sharing
    - (48 MB .7z) https://drive.google.com/file/d/155Lk0ml9AUGp5NwtTZGpdu7e7Ehdyeth/view?usp=sharing
3. Extract that into your game folder so you have a folder named jre. You'll now have both jre (with java 8 ) and jre7.
4. Make sure that your starsector/starsector-core/data/config/settings.json allowAnyJavaVersion is set to true. Then launch the game as normal.


Potential issues
- Game+launcher is zoomed in/off-center.
    Fix: Right-click Starsector, Properties, Compatibility, Change high DPI settings, tick checkbox for "Override...Scaling performed by Application"
    Thanks to Normal Dude for the fix.

* Mac/Linux JRE 8 downloads:
Linux: https://drive.google.com/file/d/1TRHjle6-MOpn1zJhtSA9yvwXIQip_F_n/view?usp=sharing
MacOS: https://drive.google.com/file/d/1PW9v_CL719buKHe69GaN9fCXcPIqDOIi/view?usp=sharing

[close]
« Last Edit: July 21, 2022, 11:23:27 AM by Ruddygreat »
Logged

sirskips

  • Ensign
  • *
  • Posts: 14
    • View Profile
Re: OutOfMemoryError: PermGen space
« Reply #2 on: January 05, 2023, 12:37:50 PM »

I did this put exactly 1 space in front and behind.
Now StarSector wont launch.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: OutOfMemoryError: PermGen space
« Reply #3 on: January 10, 2023, 04:36:58 PM »

Put the edit in the batch file (starsector-core/starsector.bat) and the terminal window should tell you why it's not starting.

Or better yet, just use Java 8 in the post above.
Logged