mojira.dev
MC-55398

100% memory usage when increasing iron golem's follow range

Summoning iron golems in command blocks with:

/summon VillagerGolem ~ ~1 ~ {Equipment:[{Count:1,id:276,tag:{ench:[{id:16,lvl:5}]}},{Count:1,id:313,tag:{ench:[{id:2,lvl:4}]}},{Count:1,id:312,tag:{ench:[{id:0,lvl:1}]}},{Count:1,id:311,tag:{ench:[{id:0,lvl:1}]}},{Count:1,id:310,tag:{ench:[{id:0,lvl:4}]}}],CustomName:Magic Golem,CustomNameVisible:1,Attributes:[{Name:generic.maxHealth,Base:999},{Name:generic.movementSpeed,Base:1.0},{Name:generic.attackDamage,Base:999},{Name:generic.followRange,Base:999}],DropChances:[1.0F,1.0F,1.0F,1.0F,1.0F]}

I haven't done much testing, but the game seems to run fine until the golem has a mob to target. once it does, mobEntitys stop moving, and spawn eggs can't be used. (I'm assuming that at this point the server has frozen) then, when you try to relog the game crashes. (crash report attached)

edit: I did more tests. See the comments.

Linked issues

Attachments

Comments 8

Incomplete without a crash report. Please attach it so the issue can be diagnosed.

Confirmed.
Crashes with an OutOfMemory error:

---- Minecraft Crash Report ----
// Don't be sad. I'll do better next time, I promise!

Time: 18.05.14 05:38
Description: Ticking entity

java.lang.OutOfMemoryError: GC overhead limit exceeded
	at dg.a(SourceFile:57)
	at ayg.e(SourceFile:1164)
	at ayg.n(SourceFile:1095)
	at om.a(SourceFile:173)
	at ayg.a(SourceFile:859)
	at om.c(SourceFile:104)
	at om.d(SourceFile:117)
	at alh.b(SourceFile:290)
	at alw.<init>(SourceFile:36)
	at alh.a(SourceFile:2422)
	at xx.a(SourceFile:97)
	at xw.a(SourceFile:151)
	at xw.a(SourceFile:139)
	at xr.a(SourceFile:60)
	at xr.apply(SourceFile:37)
	at com.google.common.base.Predicates$AndPredicate.apply(Predicates.java:343)
	at ayg.a(SourceFile:806)
	at alh.a(SourceFile:2324)
	at xq.a(SourceFile:72)
	at wg.a(SourceFile:75)
	at ut.bx(SourceFile:454)
	at us.e(SourceFile:1399)
	at ut.e(SourceFile:326)
	at yy.e(SourceFile:98)
	at us.j(SourceFile:1267)
	at ut.j(SourceFile:199)
	at alh.a(SourceFile:1441)
	at on.a(SourceFile:562)
	at alh.g(SourceFile:1419)
	at alh.i(SourceFile:1324)
	at on.i(SourceFile:435)
	at net.minecraft.server.MinecraftServer.w(SourceFile:562)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
	at dg.a(SourceFile:57)
	at ayg.e(SourceFile:1164)
	at ayg.n(SourceFile:1095)
	at om.a(SourceFile:173)
	at ayg.a(SourceFile:859)
	at om.c(SourceFile:104)
	at om.d(SourceFile:117)
	at alh.b(SourceFile:290)
	at alw.<init>(SourceFile:36)
	at alh.a(SourceFile:2422)
	at xx.a(SourceFile:97)
	at xw.a(SourceFile:151)
	at xw.a(SourceFile:139)
	at xr.a(SourceFile:60)
	at xr.apply(SourceFile:37)
	at com.google.common.base.Predicates$AndPredicate.apply(Predicates.java:343)
	at ayg.a(SourceFile:806)
	at alh.a(SourceFile:2324)
	at xq.a(SourceFile:72)
	at wg.a(SourceFile:75)
	at ut.bx(SourceFile:454)
	at us.e(SourceFile:1399)
	at ut.e(SourceFile:326)
	at yy.e(SourceFile:98)
	at us.j(SourceFile:1267)

-- Entity being ticked --
Details:
	Entity Type: VillagerGolem (yy)
	Entity ID: 51964
	Entity Name: Magic Golem
	Entity's Exact location: 455,50, 64,00, -179,50
	Entity's Block location: 455,00,64,00,-180,00 - World: (455,64,-180), Chunk: (at 7,4,12 in 28,-12; contains blocks 448,0,-192 to 463,255,-177), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
	Entity's Momentum: 0,00, -0,08, 0,00
	Entity's Rider: ~~ERROR~~ NullPointerException: null
	Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
	at alh.i(SourceFile:1327)
	at on.i(SourceFile:435)
	at net.minecraft.server.MinecraftServer.w(SourceFile:562)
	at net.minecraft.server.MinecraftServer.v(SourceFile:496)
	at clk.v(SourceFile:132)
	at net.minecraft.server.MinecraftServer.run(SourceFile:412)
	at nd.run(SourceFile:682)

-- Affected level --
Details:
	Level name: New World
	All players: 1 total; [oq['Kumasasa'/292, l='New World', x=459,65, y=63,00, z=-178,51]]
	Chunk stats: ServerChunkCache: 15164 Drop: 0
	Level seed: 2038939767044968989
	Level generator: ID 01 - flat, ver 0. Features enabled: true
	Level generator options: 3;minecraft:bedrock,3*minecraft:stone,51*minecraft:sandstone,8*minecraft:sand;2;village,biome_1,decoration,stronghold,mineshaft,dungeon
	Level spawn location: 463,00,4,00,-180,00 - World: (463,4,-180), Chunk: (at 15,0,12 in 28,-12; contains blocks 448,0,-192 to 463,255,-177), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
	Level time: 968 game time, 968 day time
	Level dimension: 0
	Level storage version: 0x04ABD - Anvil
	Level weather: Rain time: 94395 (now: false), thunder time: 135526 (now: false)
	Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true

-- System Details --
Details:
	Minecraft Version: 14w20b
	Operating System: Windows 7 (amd64) version 6.1
	Java Version: 1.8.0_05, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 105299552 bytes (100 MB) / 973602816 bytes (928 MB) up to 973602816 bytes (928 MB)
	JVM Flags: 2 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	Profiler Position: N/A (disabled)
	Player Count: 1 / 8; [oq['Kumasasa'/292, l='New World', x=459,65, y=63,00, z=-178,51]]
	Type: Integrated Server (map_client.txt)
	Is Modded: Probably not. Jar signature remains and both client + server brands are untouched.

Sorry, I would have sworn I had already attached a crash report.

Java Version: 1.6.0_31, Sun Microsystems Inc.

Your Java is ancient. Current version is 1.7.0_55 or 1.8.0_05

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.

(Sorry for the inactivity)
I tested again in 15w38b; Minecraft lagged but would not crash. Possibly because I'm using a new computer: 8 GB ram instead of 4, faster CPU, and a graphics card.

After some experimentation I isolated the cause; it is setting the FollowRange attribute to 999:

/summon VillagerGolem ~ ~1 ~ {Attributes:[{Name:generic.followRange,Base:999}]}

Further testing shows that there is no lag when there are no hostile mobs in the world (eg. superflat void world), some lag when there are only a few hostiles in the world (lag is mostly after the golem kills a hostile, but before it starts tracking another), and when I tried it in a standard minecraft world at night, the server froze (couldn't open chests) almost immediately, and F3 showed RAM usage climbing. Within a minute or two F3 said "Allocated: 100%", (apparently a limit on the JVM, as only 60% of my computer's RAM was in use and the computer did not start using swap). Once Minecraft had used all the ram it could, FPS dropped from 60 to zero. Minecraft stayed in this state for at least 10 minutes; I even held F3+C for a full minute and Minecraft wouldn't crash.

Its possible that the Iron Golem's tracking has a bug in it making it lag and eat memory (crashing some computers), but I think it is more likely that this is an inevitable result of the Iron Golem trying to track every mob in a 1 km radius. So I'm thinking that nothing needs to be fixed and map makers just need to be cautious when increasing the follow range.

edit: FYI, I tried to save and exit world, which is supposed to cause the crash, but the game doesn't respond, stays frozen on the pause screen. X-ing out of Minecraft works, but when trying to log back in it stays frozen at 0%, at which point I couldn't close the window using the X button and had to kill java from the system monitor (Ubuntu equivalent of Window's Task Manager).

@unknown in MC-60182

Don't do that or assign more memory to your server instance.

The game has to calculate 999 x 999 x 256 = ~ 256 Million possible paths every game tick...

The Einhaender

(Unassigned)

Confirmed

Minecraft 1.7.9, Minecraft 14w20b

Retrieved