Skip to content

Commit 8952d52

Browse files
committed
close tensors i forgot to close
1 parent 4f4c1d6 commit 8952d52

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/io/bioimage/modelrunner/tensorflow/v2/api030/Tensorflow2Interface.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,10 @@ public <T extends RealType<T> & NativeType<T>, R extends RealType<R> & NativeTyp
329329
for (int i = 0; i < resultPatchTensors.size(); i++) {
330330
try {
331331
rais.add(ImgLib2Builder.build((TType) resultPatchTensors.get(i)));
332+
resultPatchTensors.get(i).close();
332333
} catch (IllegalArgumentException ex) {
333-
for (org.tensorflow.Tensor tt : resultPatchTensors)
334-
tt.close();
334+
for (int j = i; j < resultPatchTensors.size(); j++)
335+
resultPatchTensors.get(j).close();
335336
throw new RunModelException(Types.stackTrace(ex));
336337
}
337338
}
@@ -410,6 +411,9 @@ protected List<String> inferenceFromShmas(List<String> inputs) throws IOExceptio
410411
ShmBuilder.build((TType) resultPatchTensors.get(i), name, false);
411412
shmaNamesList.add(name);
412413
}
414+
for (org.tensorflow.Tensor tt : resultPatchTensors) {
415+
tt.close();
416+
}
413417
return shmaNamesList;
414418
}
415419

0 commit comments

Comments
 (0)