Note: I'm not a native English speaker.
----------------------------------------
What I expected to happen was...:
javaw.exe should not exceed the memory limit imposed with the -Xmx flag.
What actually happened was...:
javaw.exe uses MUCH more memory than specified with the -Xmx flag, significantly exceeding the imposed memory limit by several gibibytes.
Steps to Reproduce:
Unfortunately, I can't think of a step-by-step list to reproduce the issue, but I believe the information supplied in this bug report should be enough.
I will try and do my best to reply with more information in a timely fashion when requested (school sucks).
----------------------------------------
When playing Minecraft in multiplayer, javaw.exe will use more and more RAM progressively (note that I didn't monitor the RAM usage over time).
After a long session, I notice javaw.exe uses WAY more memory than specified using the -Xmx flag.
This causes excessive thrashing, slowdown, and forces me to close background processes and long browsing sessions in Firefox (and I'm a heavy user of Private Browsing).
Examples:
I launch Minecraft with -Xmx2G; Minecraft uses ~5.4GiB RAM after a long session;
I launch Minecraft with -Xmx2G; Minecraft uses ~4.5GiB RAM after a long session;
EDIT: I launch Minecraft with -Xmx2G; Minecraft uses ~3.8GiB RAM after roaming and flying a bit in minecartrapidtransit.net for a few minutes; attached is a screenshot showing the memory usage as reported by the OS, and the crash report (manually triggered with F3-C) (2017-12-23_22.21.05) (note: right-clicking javaw.exe in Task Manager and choosing "Open file location" opens the following folder: C:\Program Files (x86)\Minecraft\runtime\jre-x64\1.8.0_25\bin which is the folder of the bundled Minecraft JRE).
As far as I can tell (speculations only):
The bug was observed in multiplayer only (it might or might not occur in singleplayer too);
The bug was observed when playing in minecartrapidtransit.net (it might or might not occur when playing in other servers too);
The bug was observed in recent versions of Minecraft, probably since Minecraft 1.11 (it might or might not occur in older versions too); I can't tell for sure, since there was a long period in which I haven't played Minecraft.
Solutions I tried myself and didn't work:
Launching Minecraft with various JVM arguments, including enabling large pages support (-XX:+UseLargePages) and various other tricks;
Using different resource packs.
----------------------------------------
I use the official, unmodified Minecraft client and launcher.
Attached is the crash report (holding F3-C for 10 seconds method) of one session: javaw.exe was using ~5GiB RAM (as much as I remember).
Attachments
Comments 14
Is it possible that you have other Java programs running at the same time? The system could be displaying the total amount of memory used by all java
processes. Since Minecraft says it's using only 621 MB, I don't think the number you're seeing is correct.
If the memory usage is in fact abnormally high, then it may be correlated to playing on a modded server. Does this problem also happen on vanilla servers, or other servers in general?
It is not possible I have other Java programs running (well, except for the Minecraft launcher).
I am 100% sure I use no other Java program besides Minecraft.
Even if I did use other Java programs, they would have been loaded into a process isolated from the Minecraft's Java process, because of the different JRE.
As you can see in the screenshots I attached, the Minecraft's JRE is not configured to be used by my system.
I am also absolutely sure this bug exists. It occured several times already (more than I can count), and each time I checked the memory usage in Task Manager and it was Minecraft's Java using excessive memory.
The allocated memory size reported by Java itself in the crash report is apparently incorrect.
I literally meant it when I said "I use the official, unmodified Minecraft client" - I don't play with mods (a.k.a. Forge) or use any hacked client or things like that.
The only "mods" are server-side plugins (Bukkit) that do not and cannot affect the memory usage client-side.
I made some tests with mc 1.12.2. Memory usage constantly and slowly goes up. I'm running minecraft mc on java 9 openjdk, my os - arch linux.
This can be lwjgl 2.9.4 memory leak.(heap usage doesn't go up)
My startup options: -Xmx768M
Max memory usage i seen: ~1.2GiB
Usage goes up constantly by ~2.5MiB every 10-60 secs.
This can be because of particles/nametags.
Test were made on: mc.hypixel.net
After server change(in-game hypixel server changer), jvm deallocates some memory.
But i think, this is ok. Atm i don't have any profiler to make deeper tests.
I would try using an updated javaw.exe from your own Java directory so it runs better.. then try to submit a good issue
I already tried using my system's Java 9.
It either failed to create a JVM (the game crashing immediately after pressing "Play" in launcher), or crashed when connecting to a multiplayer server.
Eventually I gave up, assuming there is some incompatible API change between Java 8 and 9 and that Minecraft isn't updated to use it.
Where does it say it's using 5 GiB of memory?