Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-261339

Memory Leak in Minecraft (Offheap, Rendering)

XMLWordPrintable

    • Plausible
    • Performance
    • Normal
    • Platform

      This issue seem to affect all published version

      The offheap memory grows and grows. 1.19.4:

      JavaArgs: -Xmx2G (-Xms2G -XX:NativeMemoryTracking=summary)=only added for observing -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
      Settings: viewdistance: 12, fps: unlimited

      results after joining world, letting finish loading, playing since 15min:

      gpumem: 0,2GB (dedicated)
      heapusage: 31%
      NMT commit: 345MB + java: 2097MB = 
      process commit: 3173MB

      results after playing another 30min:

      gpumem: 1,4GB (dedicated)
      heapusage: 32%
      NMT commit: 375MB + heap: 2097MB = 2472MB
      process commit: 5105MB

      A lof of this memory is written to pagefile, with plenty of memory avaible which means that the memory seems measured as inactive. I highly doubt memory for rendering should be every stored in the pagefile... what would be the benefit?.... All the pagefile is getting eaten up and Sysmain lags the game to hell. The game keeps freezing right before the process grows. The values are very unstable unlike i remmeber it to be. 

      Why is the native code using so much memory? Why does it grow constantly?
      In Legacy Versions of Minecraft the Leak can reach 9gb and more with same settings/jvm args.
       
      Seems happening since a Windows Update between February and June in 2022 to my knowledge. I have also reported it there already, because more applications are affected in different ways. All Minecraft Versions are affected, the more pressure the worse. It seems like the bug is not caused by MInecaft itself tho. 
      What I expected to happen was...:
      It should be around 2700MB and stable, not growing

      What actually happened was...:
      growing to 5100MB and more, unstable, eating pagefile

      Steps to Reproduce:
      1. Start Minecraft and fly around in the world, Doesnt matter if chunks have been loaded or generated before. This is why i suspect rendering to be the issue.
      2. Monitor the committed memory while doing so. Please do not use Taskmanager since it does not show paged. Use resmon.

        1. 2023-03-18_14.38.22.jpg
          2023-03-18_14.38.22.jpg
          135 kB
        2. 2023-03-18_15.05.14.jpg
          2023-03-18_15.05.14.jpg
          104 kB
        3. NativeMemoryTracking-1.png
          NativeMemoryTracking-1.png
          64 kB
        4. NativeMemoryTracking-2.png
          NativeMemoryTracking-2.png
          62 kB
        5. resmon-1.png
          resmon-1.png
          7 kB
        6. resmon-2.png
          resmon-2.png
          7 kB

            Unassigned Unassigned
            Sagub2 Sagub2
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: