mojira.dev
MC-49688

Minecraft does not properly unload chunks (bad/missing chunk garbage collection)

The minecraft server does not always properly unload the chunks that should get unloaded when a player moves out of range.

(On my small (1-5 people) server, since 1.7-ish, the problem seems to be getting even worse than it has been before.)

Almost all the region files that have been touched since the server was started, remain active and written to every 45 seconds until the minecraft server is restarted. This is a really annoying problem when it comes to the backups, since I'm using incremental backups, so only the files that have changed since the last backup will get included. Now, since the server keeps practically all the region files active and constantly writes to them, the backups will get multiple times bigger than they need to be, unless I restart the server before each backup, so that the region files stop been written to before the next backup cycle.

Also, since all the active region files are written to every 45 seconds, this generates large amounts of unneeded disk writes to my SSD, each region file being in the range of about 4-8 MB. The worst case I have caught, is after all the players had logged off (so nobody was on the server), a whole whopping 40 region files were still being kept active and written to every 45 seconds.

Since the game is built around the concept of chunks, and only those chunks are supposed to be loaded and active that are within a certain radius of the player (plus spawn chunks), I would really hope that the game would actually work as is intended, and not cause this extra stress on the system running the server.

I know Spigot (and possibly Bukkit?) has proper chunk garbage collection, but I don't want to use 3rd party solutions to fix problems that shouldn't even exist if the server worked as it is supposed to.

Note: This bug report is for a pure vanilla server, following is additional/related information from a modded server:

While playing with mods I have access to a ChunkViewer (from ChickenChunks). I have used that a lot to observe the loaded chunks on my FTB servers. Using that, I have noticed that often when the player moves around, a long strip of chunks are left loaded from the edge of the player loaded region when the player moves away. Also sometimes smaller chunk clusters remain. When I move closer to such loaded areas so that my player loaded region overlaps them, and then move away again, often those areas then unload properly.

Related issues

Comments

migrated

Does this occur with just a single user on the server? Is the box pure vanilla?

If this is causing you enough issue, I would suggest using one of the loaders you suggest while we try to reproduce, just as a temporary measure for your particular case.

migrated

Yes, the number of people doesn't really matter, it also happens with just one user. Recently it has mostly been just one user playing on the server anyway. The number of region files touched per play session is usually around 5-10, and it has recently been that all of those have been written to up until the point the server is shut down.

And yes, this server is pure vanilla, so the minecraft_server.jar provided by Mojang. This isn't such a huge issue for me that it would need any workarounds, mostly just annoying and tickles my "OCD" of minimizing server resource usage, and obviously not how the server is supposed to work. I didn't quite understand what you were saying about loaders❓

In case it helps, here is my current server startup commandline:
OPTIONS='nogui'
JVM_OPTS="-XX:+UseConcMarkSweepGC"
JVM_MEM_OPTS="-Xms128M -Xmx1024M"
INVOCATION="java $JVM_MEM_OPTS $JVM_OPTS -Dlog4j.configurationFile=log4j2.xml -jar $SERVICE $OPTIONS"

I just hope that this gets looked at and fixed soon, it might also help other servers that are struggling with server load or memory usage issues, but I haven't had any real problems with those with this small a server.

galaxy_2alex

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases. If this has been done, we can reopen the issue.

Keep in mind that the "Resolved"-Status on this ticket just means "Answered", and that we are waiting for further information on whether this issue still exists or not. We will reopen it as soon as the requested information has been delivered.

migrated

Seems to be working pretty good in 1.7.10, don't know about 1.8.x yet, since I haven't updated my servers yet because of other issues in them. I'll report back if the issue returns in 1.8.x once I feel comfortable updating, but for now it can remain as resolved from my part, based on 1.7.10.

migrated

Ticket resolved as incomplete, because no answer in a reasonable amount of time (1+ year), if it still happens, please update the ticket.

migrated

I don't know if it matters in any way, but this can properly be marked as resolved. I haven't seen this issue at all probably since somewhere around 1.8. At least in 1.10 and 1.11 things seem to work perfectly fine regarding this issue.

migrated

(Unassigned)

Plausible

Minecraft 1.7.4

Retrieved