You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Memory leaks caused by Level, Player and sometimes even Entity instances persisting between world loads are quite common, caused by mod devs using a field like public static Map<ServerLevel, SomethingElse> stuff = new HashMap<>();. A warning against these would in the IDE let the mod author know that it can cause issues and help prevent some of them. In particular for a HashMap using one of those classes as a key it can be solved by replacing it with a WeakHashMap, which will let the keys be GCed away, otherwise the solution is typically listening to unload events and clearing the contents of the field there.
Minecraft Development for IntelliJ plugin version
N/A
Description of the feature request
Memory leaks caused by Level, Player and sometimes even Entity instances persisting between world loads are quite common, caused by mod devs using a field like
public static Map<ServerLevel, SomethingElse> stuff = new HashMap<>();
. A warning against these would in the IDE let the mod author know that it can cause issues and help prevent some of them. In particular for aHashMap
using one of those classes as a key it can be solved by replacing it with a WeakHashMap, which will let the keys be GCed away, otherwise the solution is typically listening to unload events and clearing the contents of the field there.An example of one of these memory leaks:
https://github.com/AlexModGuy/AlexsMobs/blob/0d7bea8f643bff978ff2b9e4690f3c2a1a514266/src/main/java/com/github/alexthe666/alexsmobs/event/ServerEvents.java#L109
The text was updated successfully, but these errors were encountered: