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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user