fix: memory leaks (surprisingly a lot)

can't believe i forgot to remove some elements....... especially in the query plugin, which is used A LOT by the tracked core, wows.......
most of the leaks are caused by me not clearing the transactions IDs map, back in the days i didn't even know i have to do those since i didn't know i have to manage memory stuff
This commit is contained in:
ChomeNS
2025-03-06 19:03:13 +07:00
parent ece89a68c5
commit 2d67f616be
4 changed files with 13 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ import java.util.concurrent.CompletableFuture;
public class QueryPlugin extends Bot.Listener {
private final Bot bot;
private int nextTransactionId = 0;
private long nextTransactionId = 0;
private final Map<Long, CompletableFuture<String>> transactions = new HashMap<>();
private final List<UUID> ids = new ArrayList<>();
@@ -48,12 +48,14 @@ public class QueryPlugin extends Bot.Listener {
if (!(children.getFirst() instanceof TextComponent)) return true;
final long transactionId = Integer.parseInt(((TextComponent) children.getFirst()).content());
final long transactionId = Long.parseLong(((TextComponent) children.getFirst()).content());
if (!transactions.containsKey(transactionId)) return true;
final CompletableFuture<String> future = transactions.get(transactionId);
transactions.remove(transactionId);
if (children.size() == 1) {
future.complete(null);
} else {