mojira.dev
MC-241263

Off-heap memory leak

I'm experiencing an off-heap memory leak, quickly consuming my PC's RAM over minutes of creative-mode exploration.

The Java heap is otherwise behaving fine and appears to respect the assigned limit (4GB).  The memory consumption is associated with the java process.

  • Minecraft:  1.18 Pre-release 1, 21w44a

  • Launcher:  MultiMC 5 0.6.13-2519

  • Java:  OpenJDK 16.0.1+9-Ubuntu-120.04

  • OS:  Ubuntu 20.04.3

  • RAM:  16GB (system) with a 4GB Java heap allocation

  • GPU:  NVIDIA GeForce GTX 1070

  • GPU Driver:  3.2.0 NVIDIA 495.44 (nvidia-driver-495)

I'll be digging deeper into the issue but I'm unfamiliar with Java, so any tips on tracking down the source of the leak would be helpful!

Linked issues

Attachments

Comments 8

Attached a jemalloc memory allocation profile.  The heavy use of _nv014glcore makes me suspicious of the graphics driver.

[media]

MultiMC wrapper command for profiling:

sh -c "export LD_PRELOAD=/usr/local/lib/libjemalloc.so ; export MALLOC_CONF=prof:true,lg_prof_interval:30,lg_prof_sample:17,prof_prefix:/tmp/profiling/mc ; exec $INST_JAVA "$@""

The leak seems to disappear after switching to the X.Org nouveau driver (xserver-xorg-video-nouveau, "NV134 4.3 (Core Profile) Mesa 21.0.3").

From the profile, MC seems to be using a Direct3D 12 API with this driver, as opposed to OpenGL with the Nvidia driver.

[media]

Ran into a similar crash in Survival while running a world created in an earlier 1.18 snapshot. Screen turned completely grey and was unresponsive. Had to kill it from the Task Manager, which was locked to just short of 3.2 GB of memory in use.

Minecraft: 1.18 Pre-release 1
Launcher: Minecraft Launcher
Java: bundled version, no JVM argument modifications

OS: Windows 10 21H1 (19043.1348)
CPU: Intel Core i7 1165G7
GPU: Intel Iris Plus G7
GPU Driver: Intel Iris Plus Graphics 30.0.100.9955
RAM: 16 GB

[media]

Pretty sure I can confirm.

Whilst I'm not familiar with memory usage as such, I've noticed that when using a world prior to this pre-release, this issue seems to occur. I've allocated 2GB of ram to the Java heap, but when monitoring Task Manager I've been getting usage between 3-4 GB of ram after only a couple of minutes. Something that does not happen on version 1.17.1. I can also confirm that the monitoring inside the game of ram usage does not report this amount of usage. Note that I'm not able to crash the game by just flying around. 

Minecraft: 1.18 Pre-release 1
Launcher: Minecraft Launcher
OS: Windows 10 19042
CPU: AMD Ryzen 53500U
GPU: AMD Radeon Vega Mobile Gfx 8
GPU Driver: AMD Radeon Vega Mobile Gfx 8 27.20.1016.1
RAM: 8 GB

Persists in 1.18 Pre-release 2 and the latest version of OpenJDK.

  • Minecraft:  1.18 Pre-release 2

  • Java:  OpenJDK 17 (17+35-Ubuntu-120.04)

 

Some more observations:

  • The leak only appears to occur during client-side chunk loading; servers are fine, and RAM is steady while standing still.

  • Upgrading to LWJGL 3.3.0 does not fix it.

Does this still occur in 1.18-pre4?

Unfortunately it still persists in 1.18-pre4.

Oddly: reloading chunks (pressing F3+A or changing render distance) seems to reset the leak.  The leaked memory is not freed to the system, but the leaked pool does get re-used, so it takes a while to start visibly consuming memory again.

 

H2O_au

Felix Jones

Community Consensus

(Unassigned)

1.18 Pre-release 1, 1.18 Pre-release 2, 1.18 Pre-release 4

1.18 Pre-release 6

Retrieved