Index: /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkPlugin.java
===================================================================
--- /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkPlugin.java	(revision 28598)
+++ /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkPlugin.java	(revision 28599)
@@ -44,4 +44,9 @@
     // private Tag2LinkPreferenceSetting preferenceSetting; TODO
 
+    private SelectionPopupListener selectionPopupListener;
+    private MembershipPopupListener membershipPopupListener;
+    private PropertyPopupListener propertyPopupListener;
+    private RelationPopupListener relationPopupListener;
+    
     /**
      * Initializes the plugin.
@@ -69,8 +74,24 @@
         if (newFrame != null) {
             // Initialize dialogs listeners only after the main frame is created
-            newFrame.selectionListDialog.addPopupMenuListener(new SelectionPopupListener(newFrame));
-            newFrame.propertiesDialog.addMembershipPopupMenuListener(new MembershipPopupListener(newFrame));
-            newFrame.propertiesDialog.addPropertyPopupMenuListener(new PropertyPopupListener(newFrame));
-            newFrame.relationListDialog.addPopupMenuListener(new RelationPopupListener(newFrame));
+            newFrame.selectionListDialog.addPopupMenuListener(selectionPopupListener = new SelectionPopupListener(newFrame));
+            newFrame.propertiesDialog.addMembershipPopupMenuListener(membershipPopupListener = new MembershipPopupListener(newFrame));
+            newFrame.propertiesDialog.addPropertyPopupMenuListener(propertyPopupListener = new PropertyPopupListener(newFrame));
+            newFrame.relationListDialog.addPopupMenuListener(relationPopupListener = new RelationPopupListener(newFrame));
+        } else if (oldFrame != null) {
+            // Remove listeners from previous frame to avoid memory leaks
+            if (oldFrame.selectionListDialog != null) {
+                oldFrame.selectionListDialog.removePopupMenuListener(selectionPopupListener);
+            }
+            if (oldFrame.propertiesDialog != null) {
+                oldFrame.propertiesDialog.removeMembershipPopupMenuListener(membershipPopupListener);
+                oldFrame.propertiesDialog.removePropertyPopupMenuListener(propertyPopupListener);
+            }
+            if (oldFrame.relationListDialog != null) {
+                oldFrame.relationListDialog.removePopupMenuListener(relationPopupListener);
+            }
+            selectionPopupListener = null;
+            membershipPopupListener = null;
+            propertyPopupListener = null;
+            relationPopupListener = null;
         }
     }
