-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Labels
FancyNpcsEverything related to the FancyNpcs pluginEverything related to the FancyNpcs plugin
Description
I think I found a memory leak where CraftPlayer objects (and their associated PlayerJoinEvent) are retained in memory long after a player has disconnected.
The Lambda below captures 'event' or 'event.getPlayer()'
Line 27 in 5f3bb7e
() -> FancyNpcs.getInstance().getVersionConfig().checkVersionAndDisplay(event.getPlayer(), true)
Steps to Reproduce
- Install FancyNpcs on a Paper/Spigot server.
- Log in as a player with the FancyNpcs.admin permission.
- Log out.
- Take a heap dump and search for instances of CraftPlayer. The instance will remain even though the player is offline.
Proposed fix
if (!FancyNpcs.getInstance().getFancyNpcConfig().isMuteVersionNotification() && event.getPlayer().hasPermission("FancyNpcs.admin")) {
// Extract UUID to avoid capturing the Player/Event object
final java.util.UUID playerUUID = event.getPlayer().getUniqueId();
FancyNpcs.getInstance().getScheduler().runTaskAsynchronously(() -> {
org.bukkit.entity.Player player = org.bukkit.Bukkit.getPlayer(playerUUID);
if (player != null && player.isOnline()) {
FancyNpcs.getInstance().getVersionConfig().checkVersionAndDisplay(player, true);
}
});
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FancyNpcsEverything related to the FancyNpcs pluginEverything related to the FancyNpcs plugin