From 10eb9aa1be6d656c7e2aa772d5e5a9a017537154 Mon Sep 17 00:00:00 2001 From: Matthias Arzt <arzt@mpi-cbg.de> Date: Fri, 21 Aug 2020 18:52:17 +0200 Subject: [PATCH] RealARGBColorConverter: fix memory leak when calling ClassCopyProvider This line causes BDV to keep a reference to the first (or more) images shown. ClassCopyProvider keeps the keys used for creating class copies. In the key was a ImgLib2 pixel. So class copy kept a reference to the pixel. The pixel kept a reference to it's image, which than never gets garbage collected. --- src/main/java/net/imglib2/display/RealARGBColorConverter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/imglib2/display/RealARGBColorConverter.java b/src/main/java/net/imglib2/display/RealARGBColorConverter.java index 449d2b36..bc8f0a3e 100644 --- a/src/main/java/net/imglib2/display/RealARGBColorConverter.java +++ b/src/main/java/net/imglib2/display/RealARGBColorConverter.java @@ -57,7 +57,7 @@ class Instances provider = new ClassCopyProvider<>( Imp.class, RealARGBColorConverter.class, double.class, double.class ); } } - return provider.newInstanceForKey( type, min, max ); + return provider.newInstanceForKey( type.getClass(), min, max ); } public static class Imp< R extends RealType< ? > > implements RealARGBColorConverter< R > -- GitLab