Skip to content
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

Memory leak when using Bukkit#unloadWorld with save=false #9199

Closed
janrabek opened this issue May 9, 2023 · 8 comments
Closed

Memory leak when using Bukkit#unloadWorld with save=false #9199

janrabek opened this issue May 9, 2023 · 8 comments

Comments

@janrabek
Copy link

janrabek commented May 9, 2023

Timings or Profile link

You don't see any info abouit that leak in any timings.

Description of issue

When unloading worlds using Bukkit#unloadWorld with save=false they get removed from CraftServer#worlds but they still retain in the memory (especially ChunkTaskSchedulers):
Bildschirmfoto 2023-05-09 um 13 05 15

In this screenshot you see there are officially only 6 worlds loaded:
Bildschirmfoto 2023-05-09 um 13 06 00

This is a massive issue, as you don't know this through timings but only through testing.

Also one guy in the Spigot forum had the same issue:
https://www.spigotmc.org/threads/how-to-fix-memory-leak-unload-world.588677/

Plugin and Datapack List

Doesn't matter

Server config files

Doesn't matter

Paper version

Bildschirmfoto 2023-05-09 um 13 09 02

Other

No response

@janrabek
Copy link
Author

janrabek commented May 9, 2023

We observed that this issue only happened after updating to 1.19.*

@olijeffers0n
Copy link
Member

1.19.3 isn’t latest, is this the same on .4

@lynxplay
Copy link
Contributor

I am having trouble replicating this.
The test code

@EventHandler
public void on(final PlayerDropItemEvent event) {
    event.setCancelled(true);
    if (test == null) {
        test = Bukkit.createWorld(WorldCreator.name("test").keepSpawnLoaded(TriState.TRUE));
        event.getPlayer().sendMessage(Component.text("Loaded custom world `test`"));
        event.getPlayer().teleport(test.getSpawnLocation());
    } else {
        event.getPlayer().teleport(Bukkit.getWorld(NamespacedKey.minecraft("overworld")).getSpawnLocation());
        Bukkit.unloadWorld(test, false);
        event.getPlayer().sendMessage(Component.text("Unloaded custom world `test`"));
    }
}

was used to load and unload the world named "test" numerous times, while

jmap -dump:live,file=./server.hprof "$(jcmd | grep 'craftbukkit.Main' | cut -d' ' -f1)"

was used to create the heap dump. Notably this command only collects live objects, e.g. those that are still referenced.
I end up with exactly three ChunkTaskScheduler instances as expected.

I might be missing something tho, so this issue needs further triage.
It would be great if you can replicate this a) on latest and b) ensure that only live objects are captured as the GC may not have collected the now unloaded world at your point of capture.

Beyond that, spigot references for this issue are rather useless, paper rewrites pretty much the entire system there 😅

@janrabek
Copy link
Author

Hey,
I'm very sorry, it was a memory leak of FastAsyncWorldEdit. The save parameter didn't fix it, I only believed this was the issue because of the Spigot thread.

Best regards
Jan

@Kryniowesegryderiusz
Copy link

Hey, I'm very sorry, it was a memory leak of FastAsyncWorldEdit. The save parameter didn't fix it, I only believed this was the issue because of the Spigot thread.

Best regards Jan

Im sorry to dig up this thread, but could you maybe do some follow up? I have similar issue, but updating FAWE doesnt seem to help :c

@OneLiteFeather
Copy link

@jan can you provide more information about the plugins you were using with fawe on IntellectualSites/FastAsyncWorldEdit#2278 ? That might help as well.

@jan
Copy link

jan commented Jun 14, 2023

@OneLiteFeather wrong @jan.

@OneLiteFeather
Copy link

@OneLiteFeather wrong @jan.

My bad, it doesn't really differenciate between on the phone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants