isXander / Controlify

Another controller mod - for fabric!
https://www.isxander.dev/mods/controlify
GNU Lesser General Public License v3.0
138 stars 29 forks source link

[Bug] Possible memory leak? #160

Open MetroByte opened 1 year ago

MetroByte commented 1 year ago

Current Behaviour

Memory leak when open GUI, like CraftingTable, Anvil and anything else with ScreenHandlers, also items with GUI, like BookEditScreen. ScreenHandlers and Screens are stacking in the Heap.

Expected Behaviour

Screens and ScreenHandlers instances are removed by GC after GUIs closed.

Screenshots

Screenshot

Opened 20 times, got 20 instances. Without this mod I never have more than 1

Reproduction Steps

  1. Mods: Fabric Api 0.87.0+1.20.1, YetAnotherConfigLib 3.1.0+1.20, Controlify 1.6.0+1.20. Fabric Loader version 0.14.22
  2. Create a new world or load one
  3. Place or take something with GUI, in my case this is Anvil, which extends BlockEntity
  4. Open and close the placed Anvil GUI multiple times
  5. Take a Heap dump or attach a debugger (I used VisualVM 2.1.6 for a Heap Dump)
  6. Search for a screen class in Class Filter, for AnvilScreen it is class_471, ForgingScreenHandler is class_4861 and AnvilScreenHandler is class_1706, they are leaking altogether
  7. You can see a lot of class instances with references to dev.isxander.controlify.screenop.compat.vanilla.AbstractContainerScreenProcessor and dev.isxander.controlify.screenop.ScreenProcessor

Logs

No response

Mod Version

1.6.0+1.20

Controller

nothing

Bluetooth

Operating System

Windows

ARM

Additional Information

Maybe you should nullify references in Screens and ScreenHandlers in onClose to make GC working? Just assuming, I don't know how does your mod working

No controllers at all, I just used Fabulously Optimised 5.3.0-beta4 which has this mod included. Disabling Controlify mod resolves this leak.

Just to make sure...