Mod Menu

Mod Menu

36M Downloads

Opening Mods list causes huge memory spike

SnipUndercover opened this issue ยท 6 comments

commented

Hi! I'm relatively new to modded Minecraft and I'm not sure whether this is the right outlet to report such an issue.

Opening the mods menu with around 44 mod .jars causes Minecraft to freeze, following a massive, more than three-fold increase in memory usage.

The following screenshots are taken while opening the menu in the title screen.
Before:
Memory usage before opening Mods menu: around 2700 MB

After:
Memory usage after opening Mods menu: around 9200 MB

After Minecraft unfreezes and the memory spike is over, the JVM seems allocate 1GB more than before, idling at 3664 MB compared to 2693 MB.
If allowed to reach the memory cap, the freeze and memory spike will take longer.
(The client has access to 8 GB of ram via -Xmx8G; I have 32 GB installed)

On one occasion I have managed to cause Minecraft to crash due to a lack of available memory, but I cannot reproduce this again.
Here's the crash log if it's of any use.

commented

I haven't been able to properly check the memory usage, but I can confirm that for me, it takes a bit of time for Mod Menu to load, 97 mods, Mod Menu version 11.0.2 on Fabric 1.21.1.

commented

What if you edit the config (something like config/modmenu.json) and set update_checker to false?

commented

What if you edit the config (something like config/modmenu.json) and set update_checker to false?

I've turned that off and it still takes a bit of time to load.

commented

It's probably because ModMenu eagerly creates all config screens when opening the mods screen:

protected void init() {
for (Mod mod : ModMenu.MODS.values()) {
String id = mod.getId();
if (!modHasConfigScreen.containsKey(id)) {
try {
Screen configScreen = ModMenu.getConfigScreen(id, this);
modHasConfigScreen.put(id, configScreen != null);

commented

It's probably because ModMenu eagerly creates all config screens when opening the mods screen:

protected void init() {
for (Mod mod : ModMenu.MODS.values()) {
String id = mod.getId();
if (!modHasConfigScreen.containsKey(id)) {
try {
Screen configScreen = ModMenu.getConfigScreen(id, this);
modHasConfigScreen.put(id, configScreen != null);

Is there any way to counteract this lag?

commented

Probably. I may look into it in a few hours.