Reported on forum: http://www.minecraftforum.net/topic/1541173-java-memory-and-minecraft/#entry19026273
Apparently, the server "view distance" setting, which affects how many chunks are sent to the client for rendering, also affects mob spawns.
What I expected: Just like in single player, under normal circumstances the server would have radius 9 chunks loaded (radius 2= tiny render distance, radius 4=short, radius 8=normal, and load a 9th chunk out so that block ticks can affect stuff into that next chunk), and would have game effects and mobs working in that range, regardless of how many chunks were being sent to the client. Equally, if I had view distance of 15, then my clients can use "far", and things would still behave normally.
While working on server performance, memory/GC tuning, etc, I had a typo recommendation of 7 chunks instead of 9. And I got a response from someone that this severely affected mob spawns.
What I see as the bug: View range โ chunks sent from server to client for display โ should be independent of game effects โ effects are within 9 chunks, as mobs should despawn if loaded and more than 127 from a player, and a block 8 chunks away might tick and update into that 9th chunk. This should hold true whether only 4 chunks are sent to clients (overloaded network upload speed), or 15 chunks (lots of memory, bandwidth, and far vision support)
Related issues
is duplicated by
relates to
Attachments
Comments


To clarify, in what way does the view distance affect mob spawning?
As reported http://www.minecraftforum.net/topic/1541173-java-memory-and-minecraft/#entry18994172 and http://www.minecraftforum.net/topic/1541173-java-memory-and-minecraft/#entry19026273 mob spawns will be reduced if the view distance is reduced.
According to the wiki, the number of valid chunks is tossed into a formula to determine mob caps; my first curiosity is whether or not view distance affects the number of chunks used in that formula.
Confirming this bug, after our host changed the view distance down, we all started getting reduced mob spawning around us, to the point of no mobs spawning, even when there was caves around.
I only got entities flickering between 0/4-5 today while standing in the middle of a dark swamp at night time. This is with server view setting 7 with three players online.
But with setting 10, in the same spot, I got 160 with three players online
I would also like to confirm this bug. The server I have been playing on was getting very few natural mob spawns (1-2entities after standing around), after I suggested increasing the view distance to 9, the spawning behaved as normal (up to 79 entities when standing around)
This would be amazing if it was fix it has been a problem since mid beta... ๐
Confirmed. I could really need to reduce my view-distance to increase performance, but i would like to keep having mobs spawn.
+1 on this. Really hurting our server.
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.
It seems to affect 1.5 as well. I'm having a crazy glitch where endermen won't spawn on a platform in the end even though there's no other spawnable space.
I am running 1.5.1 and am currently experiencing this bug. I elected to drop the distance on my SMP server to improve performance, and am no longer seeing mob spawns, even after changing difficulty levels. I am happy to provide any troubleshooting data necessary to facilitate the resolution of this bug.
I agree with the OP, that if indeed these two functions (view distance and mob spawning) are tied together, they probably should not be. Although I admit I'm completely ignorant of the reasons behind why that might have been done, so it's entirely possible the reasons require it to remain unchanged.
Either way, I'm happy to help resolve this however I can.
Running a vanilla snapshot (13w38c currently) server and this is still an issue. View Distance 8 resulted in significant decrease in mod spawning. Setting it to default fixed the spawning issue, but some users started getting disconnect.overflow issues. Set view distance to 9, will perform further mod spawning testing.
Can this be re-opened or looked at again , since I have this issue with a friend's server. I barely see mobs in spawns and deserts in SMP. ๐
While I'm trying to hunt smileballs. Speaking of which, are there now less slimes in the swamps?

It's still open, and in fact, has never been changed to any other status or resolution. It has, however, been marked as "confirmed", by way of "community consensus". So they're aware that it's an issue. What someone (either the original reporter or a mod) needs to do is update the Affects Version/s field, assuming you're reporting that it's still an issue with 1.7.2.
This issue is back in 1.7.4. I play on "4 chunk" render distance since that is the max my computer can handle, and I see about 1-3 mobs in the whole night time. I play on hard difficulty, and I light up all of my caves. That should increase the hostile mob spawns on the surface at night significantly, not decrease it.
Guys why does the title, labels and description read "Server" ? Does this report only apply to SMP? What about SSP? I can confirm this behavior in SSP too. Does there have to be a different report for SSP?
@Marios No, remember there is technically no separate server JARs anymore. When playing the game single-player you are playing on a local server.
This is exactly why I think the "server" should be omitted. I'm afraid that the way this bug is described currently could cause the confusion that this behavior starts to occur only after the world is being opened to lan. But I see you edited it. Thanks.
I've just realized that render distance does not only affect mob spawning but block tick in general. I was afk close to my ice farm and I noticed that water blocks beyond render distance wouldn't freeze. I uploaded a screenshot.
The "Open LAN" feature is not affected by this bug since you cannot change server view distance only client view distance. (unless the client(host) render is tied with server view distance)
Really this only does affect the server, not to mention this has been a bug since beta so the aptly named server in the thread name was fine.
The main problem is not about the ticks(@Marios - you should open a new bug report for that, since your problem is different in this case), the problem is that mobs will spawn in unloaded chunks when the server's view distance(in the config) is set below the default. The server still tries to spawn mobs in the normal chunks preferring the unloaded since light level is probably 0 when unloaded.
I do not get lower spawn rates while playing SSP, I do not know how you confirmed it being lower in SSP and if it was when you activated Open to lan then that is classed as SMP not SSP.
The "Open LAN" feature is not affected by this bug
I know. This is why I wrote that the title could cause confusion. The title was "Server: View distance affects mob spawning". A more appropriate title would be "Server's viewing distance..."
Really this only does affect the server
Of course. What else could it affect? The client is not responsible for mob spawning.
The main problem is not about the ticks
How can you tell? Can you read Minecraft's code? I can't and I am not arguing with you, just asking.
I do not get lower spawn rates while playing SSP, I do not know how you confirmed it being lower in SSP
I don't know what about my writings made you think that I said so.
when you activated Open to lan then that is classed as SMP not SSP.
I didn't imply the opposite.
To make myself clear, I thought that the reporter with the title he used, he meant that this behavior only occurs in SMP. All I said was that, because SSP is in fact a local server with just one player connected, I can confirm this in SSP and I find the title confusing.
I don't know what about my writings made you think that I said so.
I can confirm this behavior in SSP too. Does there have to be a different report for SSP?
This was what made me think you were, I am not arguing just trying to get things straight.
This only does effect SMP, SSP spawns are perfectly fine to me when at low loaded chunks. This problem that is described above is a problem that was introduced in beta 1.6 (May 26, 2011) by the addition of forcing the view distance of every client user. With that said, open to lan does not reduce this view distance (only host client side view distance unless this has changed recently).
I just said what the problem was, mobs have a fixed spawn distance and the server view distance when lower then 9 will spawn the mobs in the chunks that are not loaded since they are the perfect conditions for the mob to be in(very low light level) so they spawn in the unlit unloaded chunks.
Mob spawning:
How the mob spawning works is they can spawn up to 128 blocks away this is unchanged and the problem. Mobs will still try to spawn in unloaded chunks which are more then 128 blocks away, now you may think doesn't that mean the view distance can be 8 ( 16 x 8 = 128 ), problem there is mob spawn will be better but still suffer from this problem over time since the chunk you stand on is + or - 16. Mobs do not abide by loaded chunks they abide by how far they are from the player.
The problem:
With the spawning in mind we will look to why the mobs do not despawn(which is similar to your problem but not the same). When they spawn in the unloaded chunks the server can no longer see them to update them, this is the same as when you are saying the ticks are not updating your ice. Your problem is something else as your chunk is loaded but not updating. If it is not loaded then it is doing the right thing and not updating. Back to the mobs, if the server does not check the these unloaded chunks they do not despawn and quickly fill up.
This is described in the original bug report, I have slightly expanded on the issue here and hopefully it is a little clearer. I'm not arguing with you Marios either I just don't think your ice problem is related to mob spawning and server view distance and the mob spawn is not effected in SSP because the client is purely in control over the loaded chunks and mobs are limited in that respect.
To recreate this problem:
Get the separate server change the view-distance in the sever-properties to 4 and then start the server, join the server and set your client view distance as far as you can. You can see the sun and moon and no fog but only 4 chunks are loaded, now roam around and wait for night you will see a very limit amount of mobs.
SSP automatically compensates for the lower view distance, when you have the standalone server forcing a view distance the server does not compensate mob spawning like in SSP.
Very nice post Jarod. You convinced me about the block tick issue being a different issue. But I got a little bit confused about this one.
Are you sure that in SSP, render distance and loaded chunks are tied together? Exactly for the reasons you described, meaning the problems that this would cause with mob spawning (for example), I always thought that render distance wouldn't affect loaded chunks or at least loaded chunks would never be less than 8x8 for the sake of proper mob spawning behavior. I thought that they are loaded but not rendered in order to decrease the load in gpu.
And if SSP is not affected by this bug how do you explain that mob spawning stops in Etho's simple mob trap (built at the highest chunk sections above an ocean) with render distance smaller than 8?
I do not get lower spawn rates while playing SSP, I do not know how you confirmed it being lower in SSP
I don't know what about my writings made you think that I said so.
Reading my answer I understand that it might be very confusing. By "lower" I mean lower than expected, lower than the limit of 79 when render distance is set low, not lower spawn rates in SSP (with low render distance) in comparison to SMP (with low render distance).
With regard to the question, in single player, are loaded chunks and render distance tied together:
I can't answer for short or tiny. But for far, for 164, you can be more than 8 chunks away, expect items dropped on the ground to be in unloaded chunks, and safe ... and be wrong.
Back in 125 single player, render distance could be far, and only blocks within normal render range would tick.
They are not tied.
Render distance(client side) has no affect on it, but the view-distance( server standalone) does have an affect on the way mobs spawn. I just tested to double check if the open to lan render distance(client host) had an affect on the mob spawn and it did not. It keeps the default chunk's sent at 10.
I tested to see a night with view-distance at 2 gave me one zombie with the server, I tried open to lan and SP and set the render distance to 2 and still got lots of mobs. Thing to note here is if you start the server up while night it will spawn a healthy amount of mobs but as the days go on it will get to a point where you wont see any. The main thing here isn't the mobs lose 10 or 20 every now and then, this bug makes it so it pretty much doesn't spawn anything. (with this bug I can go cave mining without torches and not have to worry)
If there is a SSP reduction by etho's trap(which you should link to where he is saying so) via a certain distance it is a different problem, this bug is directly the problem of view-distance on the standalone server. For all I know it could be related but the bug report here is to inform Mojang of the server bug which is pretty annoying for server hosts who which to have high population servers but want the lower the RAM and network overhead(which it does a lot).
There are special cases like redstone which operate beyond the view-distance sent by the server, the problem is mobs are the same so they are trying to spawn in these unloaded areas. Unlike redstone though mobs will keep spawning in these areas.
which you should link to where he is saying so
I didn't say it's confirmed by Etho. But...
Thing to note here is if you start the server up while night it will spawn a healthy amount of mobs but as the days go on it will get to a point where you wont see any.
...this is exactly what happens with 2 Etho's traps I've built in 2 worlds that run as SSP only. Entities inside it slowly become lower and lower until spawning stops and there are none left and they will never spawn again (unless I increase render distance again).
A big problem is that, like you said, it requires a considerable amount of time to observe this happening and thus it can go unnoticed and easily labeled as "cannot reproduce".
I am also experiencing this problem on my small multiplayer server. I built a mob farm in the sky and no mobs spawn whatsoever. Al though there are no caves nearby the mobs aren't spawning where they are supposed to. After reading this post I changed my view distance to 10 and I am still experiencing this problem. I am not on peaceful nor do I have nearby cave systems, because I am so high in the air.

@Jonathan, I have a similar build and I can tell you that you are experiencing a different issue. I am uncertain if it has already been reported, but mob spawning also appears to be affected by the number of players online. If you have the same issue I have observed, spawning should be normal with only 1 player online.
This is the single biggest performance issue with SMP servers, in my opinion. Back in 1.7.2 when the game was bugged and limited to a view distance of 8 my server ran great. When it was fixed, I bumped it up to 10 and quickly found my server didn't like that. Lag happened all the time. Upon attempting to lower it down to 8 again the lag nearly vanished and so did mob spawns. How does this make a lick of sense? They should be completely independent of each other. I currently have it set at 9 and it's a compromise of both with lag and spawns.
I have the exact situation Fossil has on my singleplayer world on my laptop. 8: runs fine, very low spawns of mobs. 9, still runs ok, lags sometimes, but mobs are spawning like crazy.
Just typing this as a comformation that it's likely linked to the fix of the "8 chunks bug". Let me know if I need to test anything else for you mods.
One more thing, sorry for comment spamming: it mostly seems to happen on low end machines, therefor the mods/mojang may have trouble recreating the problem. It was fine in 1.7.2 so it's not a question of whether or not our machines can handle normal spawning.
FWIW: My server has seen this problem from well before 1.7.2, and it's a bare metal server which I wouldn't consider slow.

@Bob, this problem was reported in 1.4.2, and has only started affecting singleplayer games since 1.7.
Oh, right. Derp. Because SP is now the same as MP under the hood. Sorry, forgot about that.
This bug is still accurate. I had created an issue myself for 14w11b. It is still not fixed.
This is basically the same issue as this: MC-44780
The 'issue', if it isn't a feature, is chunk loading is now based on view/render distance and Mobs don't spawn in unloaded chunks.This is most likely a feature but it's not in any change logs...
I can confirm for 14w33c. It seems that render distance 9 is the breaking point. In my mob grinder I get around 100 mobs per minute if render distance is set to 10+. And around 5 mobs per minute if render distance is set to 8-. This is not a typo and I am not over-exaggerating. The difference is so big.
When I set my server's view distance to 3, my log fills with messages like this:
[09:55:01] [Server thread/WARN]: Wrong location! (214, -605) should be (214, -606), ack['Squid'/87062614, l='swim3', x=3436.31, y=52.88, z=-9679.28]
I have verified this is not chunk corruption. I have seen these messages when the occasional chunk is corrupt. But in this case, every time I see the message, it happens exactly once per mob, then stops. The mob ID is different for every message. Corrupt chunks show the same message over and over for the same mob, so this is not a corrupt chunk.
Not only that, but I visually inspected the location and found no corrupt chunks.
I believe this message is related to mob spawn rates when view distances are low. It appears to be an off-by-one error involving only negative coordinates.
For example:
[09:37:09] [Server thread/WARN]: Wrong location! (-2, -189) should be (-2, -190), abm['Bat'/86401423, l='swim3', x=-18.62, y=17.91, z=-3023.75]
[09:54:41] [Server thread/WARN]: Wrong location! (213, -603) should be (213, -604), ack['Squid'/87062382, l='swim3', x=3411.52, y=52.83, z=-9647.45]
[09:54:44] [Server thread/WARN]: Wrong location! (214, -603) should be (214, -604), ack['Squid'/87062389, l='swim3', x=3429.66, y=51.26, z=-9647.94]
[09:55:01] [Server thread/WARN]: Wrong location! (214, -605) should be (214, -606), ack['Squid'/87062614, l='swim3', x=3436.31, y=52.88, z=-9679.28]
Seems like it only ever involves negative chunk borders.
-189 vs. -190 ; -3023.75 / 16 = -188.984375
-603 vs. -604 ; -9647.45 / 16 = -602.965625
-605 vs. -606 ; -9679.28 / 16 = -604.955
I think this is intended (Beacause the chunks are probably unloaded).
This still affects 1.8 and if the behaviour was intended I would think the developers would have resolved this as "works as inteded" by now. The difference in mob spawning behaviour between render distance 9 and 10 is quite large. It is easy to check by making an area that makes mobs not be able to spawn anywhere else in the world, switching from peaceful to normal and letting mobs spawn for 5 minutes in both view distance 9 and 10 and observing the difference. In my tests I almost didn't get any spawns at all in the same setup with view distance 8, very few in view distance 9 and an expected amount of mobs in view distance 10 (all done on a professionally hosted server with no other players on at the time). This also affects single player in the same way when setting render distance to 10, 9 and 8 respectively. For players who like having to deal with mobs it becomes quite a gamer breaker if they are forced to play on lower view distances/render distances either by their own system's limitations or by servers trying to have better performance by having lower view distances. Many servers aren't vanilla survival servers and I guess on them it doesn't matter much, but pure vanilla survival becomes a bit boring when the mobs go missing.

Confirmed for 1.8.1-pre3. Also affects mob despawning as well.

Still in 1.8.1.
Here's something if you go up like 1000 of blocks doing a /tp @p ~ ~1000 ~ and Set to Peaceful all the mobs despawn as they should, ok, but if you set it back to Easy/Normal/Hard and make sure the render distance is <10, when you do a /tp @e Player you will see mobs that spawn when you are even 1000 blocks away from the nearest place to a mob spawn. Also is important to note that if you have render distance >10 this doesn't happen.
So I think this is the big issue that is making this "no mob spawnig", mobs spawn! But to chunks that are far away enough to the player will not see any mob but still loaded to make them count to the mob cap.
You can see this if you walk from the point you are to a no rendered chunk, there are mobs! But no where they should. Thanks for read, I hope this can help to this bug fixing. ๐
I wonder if this is the same thing that's affecting my farms. My 1.8.3 server running at view distance 10 has some, interesting, affects going on. When someone is greater then 10 chunks away the farms don't just unload, they still spawn entities but those entities don't follow normal rules.
For example my iron farm, built at build limit, drops golems normally when I'm on, but when my friend who lives 14 chunks away is the only one on the farm still spawns golems but they fall 'wrong' and miss the drop shaft to lava. And then populate around town to a huge degree.

Confirmed for 1.8.7
Night (8 Chunks, Normal Difficulty): 2 Zombies, 1 Skeleton (Mobs seen/fought, all night)
Night (10 Chunks, Normal Difficulty): 6 Zombies, 4 Skeletons, 6 Creepers, 5 Spiders, 2 Endermen (Mobs seen/fought, all night)
Still in 1.8.9

I think it is effecting me in 1.9
The view distance also affects which chunks are loaded, and as such, changes mob spawning patterns.
On my friends 1.9 server, hardly any mobs were spawning, raised the view distance to 10, and it was fixed. ive never seen this bug in 1.8 but I only played single player back then.

Seems to still affect current latest snapshot 16w40a
Multiplayer vanilla server.
Runs for maybe 2, 3 hours with hostile mobs spawning happily
little later, there is 0 hostile mobs in the overworld.
Does not affect end/nether spawns. (possibly because nobody is in those)
Normal difficulty, never touched the gamerule doMobSpawning
Render Distance 11
Stills in Minecraft Java 1.12, my Slime Farm doesn't work.

Still in 18w10d, annoying as heck.
Postponed? will it be fixed in 1.13 or 1.14?
This is still happening in 1.13... when is this terrible bug going to be fixed? Many people canโt run on 10+ view distance without lag, so they should still get the same mob spawns on lower render distances.
Confirmed for 1.13.1.
Confirmed as well for 1.13.1
Confirmed for 1.13.1ย
Confirmed for 1.13.2
Is Mojang going to continue postponing after 6 years? Or will this be fixed in 1.14?

Confirmed for 18w50a. SINGLEPLAYER as well. I don't think it is render distance because I have sat for three nights, render distance 12 and Normal difficulty. E under F3 says E: 4/66 to 30/66 and Those are passive mobs from my farm. I didn't see a single hostile mob, not one. I would light up the caves and try except there were no monsters in them XD. Just in 1.12.2 this field was doing good but now, legit zero. It has gotten to the point where I get surprised when I am attacked by ANY monsters at all. Actually the Only threats are from Phantoms. Drowned also but near water. Does anybody know what Mojang is doing with this? For some comedy, I had to write something else since cut and paste screwed me the original comment. (I write in notepad usually so this wouldn't happen but La Ti Da.) Oh I just logged back into my world and E: 4/78 to 64/78 ?/77 originally. I'm not sure if that helps any but there it is. Went down to /73 just after a minute or so. I'll wait for this night to fly by before I post this just see if anything spawns... OMG nothing. I tried. I can't get a single Ender pearl. Mojang our beloved game is broken, please fix! How am I supposed to get to the End now? XD
Confirmed for 19w09a, mobs aren't spawning on my server based upon the view-distance in the server.properties file. A view-distance value of 10 seemed to work, but caused lag for my users.
19w09a confirmed except it's also affecting singleplayer, in ways you wouldn't expect. My system requires a render distance of 15 in order to begin spawning mobs anywhere near normally and it's still drastically reduced compared to last stable version.
Confirmed for 19w09a here too. I have the Render Distance set to 5 and I just couldn't find a single hostile mob in the areas surrounding my house. Playing on Normal difficulty.
Confirmed for 19w12b too. no mobs are spawning when render distance is lower than 10
Confirmed for 19w13b. Hostile mobs are still not spawning during night time with Render Distance set to 5 chunks.
It looks like this was fixed, at least on my end. In the Snapshot 19w14b, hostile mobs are finally spawning around my base during Night Time with Render Distance set to 5 Chunks.

Can some more people confirm that this is fixed?
Not fixed.
I created a new world using the snapshot with view distance set to 5, difficulty hard. I had 2 players log in and run around, generating chunks, while I built a mob farm in creative. After the mob farm was finished, those players logged out at least 10 chunks away from the mob farm and I parked myself at the proper AFK spot in survival mode. The mob farm produced 2 rotten flesh, a bow, and 3 bones after running for an hour.
I don't think this will be fixed until there are fundamental changes to the hostile mob spawn/despawn code which adjust the 128 block mob spawning radius based on view distance on the server, rather than being a hardcoded limit.
[23:16:14] [Server thread/INFO]: Starting minecraft server version 19w14b
ย
I'm using a FreeBSD jail on FreeNAS 11.2, if it makes a difference. I already have a 1.13.2 release instance running publicly, and have been running a server in some form or other since 1.8 dropped.ย
Tested on 1.14-pre1.
On a server with view distance 10:
With only one player logged in, and at a mob farm, it functions normally and many mobs spawn.
When another player logs in at another part of the world, the mobs continue to spawn, but slightly less.
On a server with view distance 5:
With only one player logged in, and at a mob farm, it functions normally and many mobs spawn.
When another player logs in at another part of the world, the mobs stop spawning...
Results:
Bug still persists.
Bug still exists - version 1.14, vanilla.
When will this not be "Postponed", and actually fixed? It's been in the game since the beginning.
The reason the bug behaves the way it does is that mobs can spawn at a radius of 128 blocks from players but if the render distance is less than 10, they can spawn in lazy chunks, where they will not despawn but still contribute to their respective mob caps. It should be less obvious with passive mobs because while they can spawn, they usually generate together with new chunks ignoring their mob cap (which is usually full for this reason).
I think a sensible option is to not even have the possibility to reduce the render distance to 9 or less. It has always been broken and no one has been counting on it for years.
Not being able to reduce the render distance below 9 would mean many players with less powerful PCs wouldn't be able to play the game anymore. It would be the worst way to fix this issue.
mobs can also spawn i think if there is a light source that should block spawns that is out of render distance
1.16 snapshots have introduced a new setting called entity distance which may or may not have patched this bug. See if this bug still occurs in the latest snapshot.
Yes it does, i tested with 4 chunk render distance and got very few slimes on a superflat world, they spawned in a tiny strip and turning it up to 16 resulted in a ton more.
This bug has partially been fixed in version 1.15 where mobs despawn in lazy chunks. After upgrading my server from 1.14.4 to 1.15.2 with a view distance of 6, I saw significant increase in mob spawning and better rates in my mob farms. But mobs in lazy chunks will not randomly despawn within 128 blocks of the player

Can confirm in 23w03a

Can confirm in 23w05a

Can confirm in 23w06a

Confirmed in 1.21.3

Given the past years of changes to mob spawning, how much of this is still an issue? Could you update the ticket based on how it works in 1.21.4+?