diff --git a/CHANGELOG.md b/CHANGELOG.md index e4702951c44..857545f9a1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ + * Keep a reference of `tensorflow.SessionOptions` in `AbstractSession` to prevent premature deallocation ([pull #297](https://github.com/bytedeco/javacpp-presets/pull/297)) * Enable CUDA in `cppbuild.sh` script for TensorFlow ([issue #294](https://github.com/bytedeco/javacpp-presets/issues/294)) * Bundle `libgomp.so.1` in JAR files of OpenCV for the sake of some Linux distributions ([issue bytedeco/javacv#436](https://github.com/bytedeco/javacv/issues/436)) * Fix `linux-armhf` and `linux-ppc64le` builds for all presets ([pull #279](https://github.com/bytedeco/javacpp-presets/pull/279)) diff --git a/tensorflow/src/main/java/org/bytedeco/javacpp/helper/tensorflow.java b/tensorflow/src/main/java/org/bytedeco/javacpp/helper/tensorflow.java index d543da2775b..9d1202bb69d 100644 --- a/tensorflow/src/main/java/org/bytedeco/javacpp/helper/tensorflow.java +++ b/tensorflow/src/main/java/org/bytedeco/javacpp/helper/tensorflow.java @@ -212,9 +212,13 @@ public StringArray createStringArray() { public static abstract class AbstractSession extends Pointer { static { Loader.load(); } + + SessionOptions options; // a reference to prevent deallocation + public AbstractSession(Pointer p) { super(p); } /** Calls {@link org.bytedeco.javacpp.tensorflow#NewSession(SessionOptions)} and registers a deallocator. */ public AbstractSession(SessionOptions options) { + this.options = options; if (NewSession(options, (Session)this).ok() && !isNull()) { deallocator(new DeleteDeallocator((Session)this)); }