Changeset 17471 in josm


Ignore:
Timestamp:
2021-01-19T07:27:13+01:00 (4 years ago)
Author:
GerdP
Message:

see #17184: Memory leaks

  • use String.intern() for field role in RelationMemberData constructor.
  • clear HistoryDataSet when last HistoryBrowserDialog instance is closed

We have route relations with +1000 members and +1000 versions. It's probably not a good idea to create all the RelationMemberData instances in advance. Will open a separate ticket for that.

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/RelationMemberData.java

    r13829 r17471  
    2727    public RelationMemberData(String role, OsmPrimitiveType type, long id) {
    2828        CheckParameterUtil.ensureParameterNotNull(type, "type");
    29         this.role = role == null ? "" : role;
     29        this.role = (role == null ? "" : role).intern();
    3030        this.memberType = type;
    3131        this.memberId = id;
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java

    r16460 r17471  
    216216        if (!MainApplication.isDisplayingMapView()) return;
    217217        if (MainApplication.getLayerManager().getLayers().isEmpty()) {
    218             data.clear();
    219             fireCacheCleared();
    220         }
     218            clear();
     219        }
     220    }
     221
     222    /**
     223     * Clear the history data.
     224     * @since 17471
     225     */
     226    public void clear() {
     227        data.clear();
     228        fireCacheCleared();
    221229    }
    222230}
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java

    r16798 r17471  
    120120            // see #17270: set focus to last dialog
    121121            new LinkedList<>(dialogs.values()).getLast().toFront();
     122        } else {
     123            // we always reload the history, so there is no need to keep it in the cache.
     124            HistoryDataSet.getInstance().clear();
    122125        }
    123126    }
Note: See TracChangeset for help on using the changeset viewer.