New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix block entity memory leak #3689
Fix block entity memory leak #3689
Conversation
I don’t think that any conflicts can arise, block entity ticks are almost always called every tick of the world roughly speaking at the end of the |
To be clear, these collections are emptied after 15 seconds in Vanilla and you're moving it to happen each tick? |
They are initially emptied every tick, but as soon as everyone exits the world, the world starts counting 300 ticks, during which it still performs cleaning and block entity ticks in general, but after that the world stops doing anything... I initially confused with this, too thought that 15 seconds is interval. |
So, the problem is here that during the inactive state, if a chunk unloads the block entity list doesn't get cleared until the next "active" tick, right? This is one way of doing it, but it adds an redundant check during the game loop which could be avoided. Could we perhaps mix into the (I was thinking about doing it on the |
It seemed to me that checking for emptiness is quite cheap, although there are no guarantees. Well, I added a check. |
src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerLevelMixin.java
Show resolved
Hide resolved
Do I need to add the ability to disable the fix in the optimization configuration category? By analogy, as it is done in #3476. Perhaps I also need to make a separate mixin in the package for optimizations? |
18d701a
to
5694a25
Compare
Fixed memory leak related to inability to unload block entities when the world is inactive (no players and forced chunks). When the world is inactive, updating and unloading entities (including block entities) takes only 300 ticks (15 seconds). Next, three special arrays for block entities are inflated and hold a huge number of block entities in memory. Now it is guaranteed that every world tick there will be cleanup of block entity arrays.
ServerLevel#tick()
:Level#tickBlockEntities()
: