From c1520a05d9d0a19b5006e03b09a5d8d1172d91bb Mon Sep 17 00:00:00 2001 From: Samuel Audet Date: Tue, 2 Mar 2021 17:07:35 +0900 Subject: [PATCH] * Ensure `System.gc()` never gets called with "org.bytedeco.javacpp.nopointergc" (issue tensorflow/java#208) --- CHANGELOG.md | 1 + src/main/java/org/bytedeco/javacpp/Pointer.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c74f1a29..0031dea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ + * Ensure `System.gc()` never gets called with "org.bytedeco.javacpp.nopointergc" ([issue tensorflow/java#208](https://github.com/tensorflow/java/issues/208)) * Add `Info.immutable` to disable generating setters for public data members ([pull #461](https://github.com/bytedeco/javacpp/pull/461)) * Map `String` to `char*` with `Charset.forName(STRING_BYTES_CHARSET)` when that macro is defined ([pull #460](https://github.com/bytedeco/javacpp/pull/460)) * Fix `Loader.ClassProperties` not always getting overridden correctly when defined multiple times diff --git a/src/main/java/org/bytedeco/javacpp/Pointer.java b/src/main/java/org/bytedeco/javacpp/Pointer.java index 8df659fd..1e4b6fb9 100644 --- a/src/main/java/org/bytedeco/javacpp/Pointer.java +++ b/src/main/java/org/bytedeco/javacpp/Pointer.java @@ -671,7 +671,7 @@ protected

P deallocator(Deallocator deallocator) { synchronized (DeallocatorThread.class) { try { while (count++ < maxRetries && ((maxBytes > 0 && DeallocatorReference.totalBytes + r.bytes > maxBytes) - || (maxPhysicalBytes > 0 && lastPhysicalBytes > maxPhysicalBytes))) { + || (maxPhysicalBytes > 0 && lastPhysicalBytes > maxPhysicalBytes)) && referenceQueue != null) { if (logger.isDebugEnabled()) { logger.debug("Calling System.gc() and Pointer.trimMemory() in " + this); }