﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
15709	Big image memory leak	anonymous	team	"Since a very long time (maybe 2 years, but it could be much longer), I have a big problem to work with JPEG geo images.
If I do one day of outdoor mapping, I have 1000-2000 JPEG images, but I'm only able to open less than 100 until JOSM fails.
I really hope, that there will by a fix!

JOSM seems to allocate memory for shown images, but does not release the memory.

This is the memory usage in MB (shown by htop):

{{{
Before opening the first image:
786

After first image:
973

After second image:
1097

Every line shows the memory usage after opening another image:
1101
1095
1097
1097
1097
1097
1098
1244 (big increase)
1280
1280
1280
1308
1308
1410 (big increase)
1442
1440
1443
1732  (big increase)
1732
1734
1734
1792
1792
1892  (big increase)
1892
1926
1928
1929
1927
2155  (big increase)
2155
2155
2170
2174
2165
2169
2170
2172
2173
2172
2172
2172
2172
2272  (big increase)
2270
2270
2270
2274
2273
2274
2559  (big increase)
2564
2561
2565
2566
2568
2568
2569
2571
2570
2570
2601
2601
2601
2597
2597
2598
2596
2596
2597
2640
2638
2639
2643
2643
2639
2640
2640
2639
2640
2640
2639
2637
2637
2637
2635
2635
2636
2637
2635
2637
2637
2637
2637
2637

JOSM now uses 2639 MB - 786 MB = 1853 MB because I displayed 97 images, after that, JOSM starts to fail to display some images until it is completely out of memory.
I don't think JOSM should use that much memory for images, less than 200 MB should be enough for an endless number of images.

error loading image file
2635
2637
2635
error loading image file
2637
2635
2637
2637
2637
error loading image file
2539
error loading image file
2639
error loading image file
2639
2637
error loading image file
2639
error loading image file
2638
error loading image file
error loading image file
}}}

Now JOSM is out of memory:

{{{
2017-12-30 12:22:59.912 SCHWERWIEGEND: Handled by bug report queue: java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
        at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:75)
        at java.awt.image.Raster.createPackedRaster(Raster.java:467)
        at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
        at java.awt.image.BufferedImage.<init>(BufferedImage.java:324)
        at org.openstreetmap.josm.gui.layer.geoimage.ImageDisplay$LoadImageRunnable.run(ImageDisplay.java:328)
        at java.lang.Thread.run(Thread.java:748)
}}}

Even if I close the image window and the image layer, JOSM does not free the memory:
2643 MB

I did the whole test, without any data layer, I just opened the images (8 megapixels).


This is what JOSM shows me, after out of memory and after I closed the image window and the image layer:


{{{
URL:http://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2017-12-28 23:33:18 +0100 (Thu, 28 Dec 2017)
Build-Date:2017-12-29 02:32:16
Revision:13257
Relative:URL: ^/trunk

Identification: JOSM/1.5 (13257 de) Linux Debian GNU/Linux 9.3 (stretch)
Memory Usage: 2389 MB / 2389 MB (71 MB allocated, but free)
Java version: 1.8.0_151-8u151-b12-1~deb9u1-b12, Oracle Corporation, OpenJDK 64-Bit Server VM
Java package: openjdk-8-jre:amd64-8u151-b12-1~deb9u1
Java ATK Wrapper package: libatk-wrapper-java:all-0.33.3-13

Last errors/warnings:
- E: Handled by bug report queue: java.lang.OutOfMemoryError: Java heap space
}}}

JOSM is started with ""-Xmx2400M""."	defect	closed	normal	18.01	Core image mapping		fixed	memory leak ImageTracker ImageMediaEntry ImageDisplay.java	
