MemoryLeakFix

MemoryLeakFix

13M Downloads

Incompatible with Lithium

wendavid552 opened this issue ยท 4 comments

commented

Test Environment

Minecraft 1.18.2, fabric
MemoryLeakFix v0.8.0
Lithium v0.10.3

Reproduce Step:

  1. /summon an minecraft:axolotl in water at 0 0
  2. Move away 128 blocks to despawn the axolotl
    Result:
    Game crash with:
java.util.NoSuchElementException: No value present
	at java.base/java.util.Optional.get(Optional.java:143)
	at net.minecraft.class_4119.method_18919(class_4119.java:52)
	at net.minecraft.class_4821.method_18919(class_4821.java:32)
	at net.minecraft.class_4097.method_18922(class_4097.java:45)
	at net.minecraft.class_4095.method_18891(class_4095.java:512)
	at net.minecraft.class_4095.method_19542(class_4095.java:471)
	at net.minecraft.class_5762.method_5958(class_5762.java:359)
	at net.minecraft.class_1308.method_6023(class_1308.java:759)
	at net.minecraft.class_1309.method_6007(class_1309.java:2609)
	at net.minecraft.class_1308.method_6007(class_1308.java:546)
	at net.minecraft.class_1296.method_6007(class_1296.java:127)
	at net.minecraft.class_1429.method_6007(class_1429.java:58)
	at net.minecraft.class_1309.method_5773(class_1309.java:2354)
	at net.minecraft.class_1308.method_5773(class_1308.java:346)
	at net.minecraft.class_3218.method_18762(class_3218.java:702)
	at net.minecraft.class_1937.method_18472(class_1937.java:485)
	at net.minecraft.class_3218.method_31420(class_3218.java:363)
	at net.minecraft.class_5574.method_31791(class_5574.java:54)
	at net.minecraft.class_3218.method_18765(class_3218.java:331)
	at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:907)
	at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:851)
	at net.minecraft.class_1132.method_3748(class_1132.java:97)
	at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:697)
	at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:273)
	at java.base/java.lang.Thread.run(Thread.java:1589)

In fact it is in net.minecraft.entity.ai.brain.task.FollowMobTask.shouldRun() with

        LivingTargetCache livingTargetCache = entity.getBrain().getOptionalMemory(MemoryModuleType.VISIBLE_MOBS).get();

Attempts to fix it

I guess the fix added for MC-260605 conflicts with lithium. Lithium perhaps add some shouldRun() check after the entity is removed (), so I do some test.
In fact I disable mixin.ai.task.memory_change_counting in lithium.properties and it gets fixed. Seems the latest versioin of Lithium does not change much of the code here so perhaps there's also issue there. I would test it later.

Suggestion

I suggest using an Inject rather than overwritting LivingEntity.remove().

You could refer to the fix code here. It works with Lithium on 1.18.2.

commented

I'm getting the same error with a naturally spawned axolotl:

-- Entity being ticked --
Details:
	Entity Type: minecraft:axolotl (net.minecraft.class_5762)
	Entity ID: 145
	Entity Name: Axolotl
	Entity's Exact location: 1498.61, 23.00, -843.12
	Entity's Block location: World: (1498,23,-844), Section: (at 10,7,4 in 93,1,-53; chunk contains blocks 1488,-64,-848 to 1503,319,-833), Region: (2,-2; contains chunks 64,-64 to 95,-33, blocks 1024,-64,-1024 to 1535,319,-513)
	Entity's Momentum: -0.01, 0.00, -0.12
	Entity's Passengers: []
	Entity's Vehicle: null
Stacktrace:
	at net.minecraft.class_1937.method_18472(class_1937.java:485)
	at net.minecraft.class_3218.method_31420(class_3218.java:363)
	at net.minecraft.class_5574.method_31791(class_5574.java:54)
	at net.minecraft.class_3218.method_18765(class_3218.java:331)
	at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:907)
	at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:851)
	at net.minecraft.class_1132.method_3748(class_1132.java:97)
	at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:697)
	at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:273)
	at java.base/java.lang.Thread.run(Thread.java:833)

I'm using Lithium 0.10.3 and Memory Leak Fix 1.18.2-0.8.0. Doesn't happen when I downgrade to MemoryLeakFix 0.7.0

commented

This is already fixed internally. It will be in the next release, however it may take some time. Since the next release is a Major change

commented

Still happing with v1.0.0-beta.4. Crash reports are identical to wendavid552's.

commented

Please try beta 5