﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
19789	[RFC patch] memory leak with gpx waypoints	GerdP	GerdP	"==== What steps will reproduce the problem?
1. load a gpx file with many waypoints  (wpt)
2. remove the new layers created by step 1
3. repeat 1+2

==== What is the expected result?
Each repetition should show roughly the same load time
==== What happens instead?
load times are increasing
{{{
2020-09-13 14:47:38.878 INFO: Open file: D:\mkgmap\land_hp.gpx (1489503 bytes)
2020-09-13 14:47:41.853 INFO: Open file: D:\mkgmap\land_hp.gpx (1489503 bytes) completed in 3.0 s
2020-09-13 14:49:16.120 INFO: Open file: D:\mkgmap\land_hp.gpx (1489503 bytes)
2020-09-13 14:49:24.141 INFO: Open file: D:\mkgmap\land_hp.gpx (1489503 bytes) completed in 8.0 s
2020-09-13 14:49:56.095 INFO: Open file: D:\mkgmap\land_hp.gpx (1489503 bytes)
2020-09-13 14:50:09.118 INFO: Open file: D:\mkgmap\land_hp.gpx (1489503 bytes) completed in 13.0 s
}}}
==== Please provide any additional information below. Attach a screenshot if possible.
Problem is in class `Marker` which adds a listener for each way point (wpt):
{{{
#!java
Preferences.main().addKeyPreferenceChangeListener(""draw.rawgps."" + getTextTemplateKey(), l -> updateText());
}}}
These listeners are not removed when the marker layer is closed. So, this eats up memory and the method `addListener()` calls `ensureNotInList()` which does a sequential search over all listeners. My test file contains > 32.000 points
{{{
URL:https://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2020-09-06 16:54:59 +0200 (Sun, 06 Sep 2020)
Build-Date:2020-09-07 01:30:48
Revision:17013
Relative:URL: ^/trunk

Identification: JOSM/1.5 (17013 en) Windows 10 64-Bit
OS Build number: Windows 10 Home 2004 (19041)
Memory Usage: 895 MB / 3641 MB (200 MB allocated, but free)
Java version: 1.8.0_221-b11, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Look and Feel: com.sun.java.swing.plaf.windows.WindowsLookAndFeel
Screen: \Display0 1920x1080 (scaling 1.0x1.0)
Maximum Screen Size: 1920x1080
Best cursor sizes: 16x16 -> 32x32, 32x32 -> 32x32
VM arguments: [-XX:StartFlightRecording=name=MyRecording2,settings=d:\dbg\gerd.jfc, -XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true,dumponexitpath=e:\ld\perf_20200913_144555.jfr]

Plugins:
+ OpeningHoursEditor (35414)
+ PolygonCutOut (v0.7)
+ apache-commons (35524)
+ buildings_tools (35500)
+ continuosDownload (91)
+ ejml (35313)
+ geotools (35169)
+ jaxb (35092)
+ jts (35122)
+ merge-overlap (35248)
+ o5m (35248)
+ opendata (35513)
+ pbf (35446)
+ poly (35248)
+ reverter (35499)
+ undelete (35521)
+ utilsplugin2 (35487)
}}}
"	defect	closed	normal	20.09	Core		fixed	template_report performance gpx	simon04 taylor.smock
