Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak with switching worlds & dimensions #635

Closed
Ampflower opened this issue Nov 27, 2022 · 6 comments · Fixed by Creators-of-Create/Create#4108
Closed

Memory Leak with switching worlds & dimensions #635

Ampflower opened this issue Nov 27, 2022 · 6 comments · Fixed by Creators-of-Create/Create#4108
Labels
type: bug Issue where something isn't working

Comments

@Ampflower
Copy link

Ampflower commented Nov 27, 2022

Describe the Bug

Create has been found to leak on Quilt with both Quilted and Fabric API Indigo. Further testing is needed to determine if it is an upstream issue with the Forge version of Create. After further testing, this report is not applicable to be forwarded upstream. The only part of Create on Forge that retains memory is Flywheel, which seems to be temporary at most, as it hasn't caused any extreme memory usage on its own.

Reproduction Steps

  1. Set the render distance sufficiently high to show the memory leak quickly. 8-16 chunks shows this pretty quickly.
  2. Set the memory limit low to show the effects of the memory leak quickly.
    • -Xmx1G was chosen with Lithium, LazyDFU and FerriteCore installed.
    • You may want 2-4G without LazyDFU and FerriteCore.
  3. Load any world.
    • A Create contraption does not need to be present.
    • A server is applicable.
    • A server not running Create may also work for this case.
  4. Switch dimensions or worlds several times or until the garbage collector starts killing frame time.
  5. Optional: Heap dump the client at this time using JDK Mission Control (I would highly recommend for quick transversal of the object tree, as this will be highly duplicated by nature), VisualVM, jcmd, or Spark, if installed.
  • You may alternatively use a heap dump on out of memory flag and continue doing above until the game crashes.

Expected Result

For the client to continue running normally without any (notable) leak from Create or any other mod present.

Screenshots and Videos

No response

Crash Report or Log

N/A - This doesn't cause a crash unless you continue.

Operating System

Arch Linux + Kernel 5.19.11-arch1-1 + Mesa 22.2.1

Mod Version

0.5.0g

Minecraft Version

1.19.2

Other Mods

  • Quilt Loader 0.18.1-beta.18
  • AppliedEnergistics2 Fabric 12.8.5
  • BetterRecipes 1.3.0
  • Botania 1.19.2-436-FABRIC (Commit de969aab76868a60e5d1ae4b62d1f377ec740f03)
  • Ears 1.19-1.4.6
  • Fabric API 0.67.1+1.19.2 OR QFAPI-4.0.0-beta.21+QSL-3.0.0-beta.21+FAPI-0.67.0+MC-1.19.2
  • FastBench 1.19.2-3 (PR Update to 1.19.2 and fix various bugs Tfarcenim/FabricFastBench#22)
  • FerriteCore 5.0.0
  • Gadget 0.1.3
  • LazyDFU 0.1.3
  • Lithium 1.19.2-0.10.2
  • owo-lib 0.8.3+1.19
  • Patchouli 1.19.2-77-FABRIC
  • Tom's Storage 1.19-1.4.3
  • Trinkets 3.4.1
  • YetAnotherConfigLib 1.7.1

Additional Context

  • Logistics (Found via VisualVM)
    Stack trace from a palette to GC root entering Create

  • Flywheel (Found via VisualVM)
    Stack trace from a palette to GC root entering Flywheel

  • com.simibubi.create.foundation.utility.WorldAttached.attached (Found via JMC)
    Stack trace from a PackedIntegerArray to a GC root entering Create
    4 classes from above unmangled
    Another stack trace from PackedIntegerArray

  • com.simibubi.create.content.logistics.trains.track.TrackBlockOutline:TRACKS_WITH_TURNS

@Ampflower Ampflower added the type: bug Issue where something isn't working label Nov 27, 2022
@github-actions github-actions bot added the 1.19 label Nov 27, 2022
@Ampflower
Copy link
Author

This does not appear to be an issue upstream with Forge 43.1.7 + Flywheel 0.6.7-8 + Create 0.5.0.f. This report is not applicable to be forwarded upstream.

@Ampflower
Copy link
Author

Ampflower commented Nov 27, 2022

Out of curiosity: Memory leak is still present with just:

  • Quilt Loader 0.18.1-beta.18
  • Fabric API 0.67.1
  • Create 0.5.0g
  • LazyDFU 0.1.3

Which practically kills it nearly immediately on -Xmx1G

Update: 269M is retained after setting -Xmx2G and going between the nether and overworld several times with the above mod set minus LazyDFU.

@Ampflower
Copy link
Author

Ampflower commented Nov 27, 2022

9fbb71e seems like the commit that has fixed it upstream. Will check for its presence here. It is present, but it's still leaking? Is there some other relations that's causing leaking that just isn't present in a Forge environment?

@Ampflower
Copy link
Author

Reproduced issue with b7a90f3 in dev.
Annoyingly, VisualVM's compare heap dumps feature doesn't actually work for this.

@Ampflower
Copy link
Author

It looks like WorldAttached is not getting a clear call for the ClientLevel, examining the invalidateWorld call with a debugger, and only counting 3 ServerLevels passing through it

@Ampflower
Copy link
Author

A defence of using a WeakHashMap at WorldAttached.attached can help avoid memory leaks by missed calls, but this is only a band-aid around the root problem: invalidateWorld not getting the ClientLevel call on Fabric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Issue where something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants