mojira.dev
MCPE-77266

Mobs remain in memory

Memory clean up for mobs and entities does not seem to occur. 

Steps to reproduce

name tag a mob (or spawn a unique mob of any type). execute the following command

  1. /tp @s ~+1000 ~ ~+1000

  2. Wait for several minutes or hours at that location.

  3. run the following command:

    /execute @e [name="nametagedname"] ~~~ say hi

Expected result

You get a red message saying "No targets matched selector"

Actual result

Jim says "hi."

The root issue is that over time CPU and RAM usage creep up over time causing large amounts of lag on busy servers. Right now this causes a forced reboot of the BDS software frequently to empty the memory.

This may be reduced with mob despawning however it still is a memory leak that causes things to go way up over time. In small quantities it is not a problem, however with a world spawning thousands of blocks and has many players, this becomes a major issue.

Related issues

Comments

ravinmaddhatter

The easy way is to put a command block on repeat every 300 or so ticks, and run the command "spreadplayers 0 0 5000 5001 @a" on repeat. the more players you have in the world the faster the bug will repro. 

Server resets clear the issue, but it builds up quickly on servers.

Happens on BDS, on Realms, and local

GoldenHelmet

It makes sense for mobs to be kept in memory for a period of time after chunks are out of simulation distance because then they won't need to be re-loaded if the player soon moves back to where it had been. Also, in some cases it is beneficial, such as if you have a sprawling village it is better to keep all villagers loaded so that some are not dropped from the dwellers list, which can cause problems like stolen POI and infinite breeding. However, I would not have expected that the mobs are never cleared out memory until relog/reset. I would expect that a combination of distance and time since last memory access could be used to unload mobs (and chunks) to optimize performance.

Jonathan5733

I don't know if this is the same, but I discovered a memory leak with entities in 1.16.20, where if you kill an entity it remains in memory (e.g. I use /kill @e to kill 300 entities, the 300 entities are still in memory, causing over 60% of my RAM being used) until the world is reloaded.

migrated

Good find, I sincerely hope this gets addressed, the lag is unbearable in this update

migrated

GoldenHelmet can you link this report with MCPE-99760 ?

Jonathan5733

Affects 1.16.100.60, more noticeable on computers with smaller amounts of RAM (less then 4GB)

Jonathan5733

Affects 1.16.200.51

Jonathan5733

Please verify if this occurs in 1.16.100

Jonathan5733

Affects 1.16.210.50

Jonathan5733

Affects 1.16.201

Jonathan5733

Affects 1.16.230.54

Jonathan5733

Affects 1.17.0.50

GoldenHelmet

In singleplayer, most mobs are removed from memory when you change dimensions, but mobs within roughly 7 chunks of the player spawn point are not (see MCPE-134908). However, I am not sure if this works in multiplayer.

migrated

Affects 1.17.40.20

Jonathan5733

Affects 1.18.20.25

Jonathan5733

Affects 1.18.30

Jonathan5733

Affects 1.19.0.34 and 1.19.0.35

Jonathan5733

Affects 1.20.80

Jonathan5733

Affects 1.21.10.20

Note to mods: Since the original reporter has been inactive for over two years, I wish to take ownership of this report so I can update affected versions and continue maintaining this report.
Jonathan5733

Affects 1.21.20.21

Jonathan5733

Affects 1.21.2

Jonathan5733

Affects 1.21.20.23

Jonathan5733

Affects 1.21.30.22

Jonathan5733

Affects 1.21.30.24

Jonathan5733

This appears to be fixed in 1.21.40.20

Jonathan5733

Fixed in 1.21.51

[Mod] OcelotOnesie

Thank you for your report!
After consideration, the issue is being closed as Won't Fix.

Please note that this is not the same as Working as Intended, as this bug report correctly describes behavior in the game that might not be the intended or desirable behavior, but it will not be fixed right now. Sometimes, this is because the issue reported is minor and/or impossible to change without large architectural changes to the code base.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

ravinmaddhatter

(Unassigned)

364059

Confirmed

Multiple

BDS, Realm, Windows 10

mobs, optimization

1.17.0.50 Beta, 1.16.230.54 Beta, 1.16.220, 1.14.60 Hotfix, 1.16.20, ..., 1.18.31, 1.19.0, 1.19.30, 1.21.20.21 Preview, 1.21.2 Hotfix

Retrieved