Performance: fixed memory leaks on each card viewer or draft open (10 Mb per call, related to #11285, fixes #9548)

This commit is contained in:
Oleg Agafonov 2023-10-14 12:38:32 +04:00
parent ce311fd691
commit 36ccfb0a2a
13 changed files with 44 additions and 10 deletions

View file

@ -24,6 +24,10 @@ import java.text.SimpleDateFormat;
import java.util.*;
/**
* Network: client side session
*
* Only one session/server per GUI's client
*
* Created by IGOUDT on 15-9-2016.
*/
public final class SessionHandler {

View file

@ -167,6 +167,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
MageFrame.getPreferences().put(KEY_DECK_EDITOR_SEARCH_RULES, Boolean.toString(chkRules.isSelected()));
MageFrame.getPreferences().put(KEY_DECK_EDITOR_SEARCH_TYPES, Boolean.toString(chkTypes.isSelected()));
MageFrame.getPreferences().put(KEY_DECK_EDITOR_SEARCH_UNIQUE, Boolean.toString(chkUnique.isSelected()));
ExpansionRepository.instance.unsubscribe(setsDbListener);
}
public void changeGUISize() {

View file

@ -40,6 +40,7 @@ public final class CollectionViewerPanel extends JPanel {
public void cleanUp() {
this.hidePopup();
this.bigCard = null;
ExpansionRepository.instance.unsubscribe(setsDbListener);
}
private void reloadFormatCombobox() {
@ -220,7 +221,6 @@ public final class CollectionViewerPanel extends JPanel {
if (c != null) {
((CollectionViewerPane) c).removeFrame();
}
}
private final class MageBookContainer extends JPanel {

View file

@ -3,6 +3,7 @@ package mage.client.util;
import java.io.Serializable;
/**
* TODO: there are duplicated interfaces of EventSource, must combine in single
* @author BetaSteward_at_googlemail.com
*/
public interface EventSource<E extends Event> extends Serializable {

View file

@ -7,6 +7,7 @@ import mage.constants.SetType;
import mage.deck.Standard;
import mage.game.events.Listener;
import javax.swing.*;
import java.util.*;
/**
@ -54,6 +55,7 @@ public final class ConstructedFormats {
}
}
};
// it's a static, so no needs to unsubscribe later
ExpansionRepository.instance.subscribe(setsDbListener);
}