SKCraft / Launcher

🚀 Distribute your Minecraft modpacks with a custom launcher
Other
617 stars 431 forks source link

Launcher uses 1GB RAM AFTER launch; Is there a line limiter in the source code? #94

Open ajthemacboy opened 8 years ago

ajthemacboy commented 8 years ago

Hello, in my custom pack I recently discovered that the launcher uses around 1GB of memory after launching the game, even when the game is fully loaded. Note that this is the launcher running in the background, not the game itself.

After checking the log I discovered that most of the log is EnderIO, Extra Utilities, JABBA, and DragonAPI spam about materials and such. At the end of launching, the startup log is 19MBs.

Why is the launcher using so much RAM, even when the log window is closed? The only way to free the RAM is to kill the launcher manually (from task manager, pkill, etc.)

What is happening?

sk89q commented 8 years ago

Because it's Java really. Java does not free memory back to the OS either.

You can change the number of lines here: https://github.com/SKCraft/Launcher/blob/adf90941e0f46547ba0eafa0da6fe16e38f4c6b9/launcher/src/main/java/com/skcraft/launcher/launch/LaunchProcessHandler.java#L27

You can also turn off color mode. I think the color mode is significantly more heavy.

Change true to false: https://github.com/SKCraft/Launcher/blob/adf90941e0f46547ba0eafa0da6fe16e38f4c6b9/launcher/src/main/java/com/skcraft/launcher/launch/LaunchProcessHandler.java#L44

ajthemacboy commented 8 years ago

Is there a way I can make the launcher terminate after launching?

Update: Tried with the line limit set to 1, just for testing, and with color disabled. I discovered that the launcher RAM usage increases dramatically (400MBs in about 30 seconds) when EnderIO begins loading. EnderIO spams a ton of lines to the log.

The log is only 20 MBs after the game finishes loading, so surely that isn't why?

sk89q commented 8 years ago

Not yet. It's been requested. I plan to look into it.

The launcher also sends output from the game to a Java logger. It could be doing all sorts of things.

Here's the code that consumes messages from the Minecraft process: https://github.com/SKCraft/Launcher/blob/master/launcher/src/main/java/com/skcraft/launcher/launch/LaunchProcessHandler.java#L48

Theoretically you could do System.exit(0) there, although this is probably a better place for it:

https://github.com/SKCraft/Launcher/blob/7b764241bf5255ef79d7179303badf1482f9cb07/launcher/src/main/java/com/skcraft/launcher/launch/LaunchSupervisor.java#L147

ajthemacboy commented 8 years ago

I added System.exit(0) to https://github.com/SKCraft/Launcher/blob/master/launcher/src/main/java/com/skcraft/launcher/launch/LaunchProcessHandler.java#L48

and changed

https://github.com/SKCraft/Launcher/blob/master/launcher/src/main/java/com/skcraft/launcher/launch/LaunchProcessHandler.java#L46

to false, and it's just what I needed. Thanks!

However, I also tried disabling color and limiting the number of lines, and the launcher still uses 600-800MBs of RAM in the background, so there's still a bug here.