Mojira Archive
MC-261339

Memory Leak in Minecraft (Offheap, Rendering)

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.

Unresolved

Sagub2

2023-03-25, 10:43 PM

2023-11-13, 11:16 PM

2

2

Plausible

Normal

Platform

Performance

Memory-usage, chunk-loading, chunk-updates, lag, memory, memory-allocation, memory-leak, memory-spikes, rendering, world

1.19.4 - 23w45a1.19.4, 23w12a, 1.20, 1.20.1, 23w33a, 1.20.2, 23w45a

-