Changeset 18942 in josm for trunk


Ignore:
Timestamp:
2024-01-19T09:11:18+01:00 (11 months ago)
Author:
GerdP
Message:

fix #23419: Memory leak in SessionSaveAction

  • don't keep references to the layers
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/SessionSaveAction.java

    r18833 r18942  
    156156     */
    157157    public boolean saveSession(boolean saveAs, boolean forceSaveAll) throws UserCancelException {
     158        try {
     159            return saveSessionImpl(saveAs, forceSaveAll);
     160        } finally {
     161            cleanup();
     162        }
     163    }
     164
     165    private boolean saveSessionImpl(boolean saveAs, boolean forceSaveAll) throws UserCancelException {
    158166        if (!isEnabled()) {
    159167            return false;
     
    369377
    370378        /**
    371          * Initializes action.
     379         * Initializes some action fields.
    372380         */
    373         public final void initialize() {
     381        private void initialize() {
    374382            layers = new ArrayList<>(getLayerManager().getLayers());
    375383            exporters = new HashMap<>();
     
    613621    }
    614622
     623    protected void cleanup() {
     624        layers = null;
     625        exporters = null;
     626        dependencies = null;
     627    }
     628
    615629}
Note: See TracChangeset for help on using the changeset viewer.