From 6aee52e4573dd31f1bff27a5b029adc072a27ca2 Mon Sep 17 00:00:00 2001 From: Samuel Audet Date: Tue, 5 May 2020 12:22:37 +0900 Subject: [PATCH] * Fix memory leak that occurs with "org.bytedeco.javacpp.nopointergc" (issue bytedeco/javacpp-presets#878) --- 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 403990f7d..dc8e6895c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ + * Fix memory leak that occurs with "org.bytedeco.javacpp.nopointergc" ([issue bytedeco/javacpp-presets#878](https://github.com/bytedeco/javacpp-presets/issues/878)) * Take into account `platform.library.path` when extracting executables and their libraries on `Loader.load()` ([issue bytedeco/javacv#1410](https://github.com/bytedeco/javacv/issues/1410)) * Move init code for `Loader.getPlatform()` to `Detector` to avoid warning messages ([issue #393](https://github.com/bytedeco/javacpp/issues/393)) * Add `HyperslabIndex` class with `offsets`, `strides`, `counts`, and `blocks` parameters ([pull #392](https://github.com/bytedeco/javacpp/pull/392)) diff --git a/src/main/java/org/bytedeco/javacpp/Pointer.java b/src/main/java/org/bytedeco/javacpp/Pointer.java index 17f164cc3..15d44b324 100644 --- a/src/main/java/org/bytedeco/javacpp/Pointer.java +++ b/src/main/java/org/bytedeco/javacpp/Pointer.java @@ -718,6 +718,7 @@ public void deallocate() { * @param deallocate if true, deallocates, else does not, but disables garbage collection */ public void deallocate(boolean deallocate) { + DeallocatorReference r = (DeallocatorReference)deallocator; if (deallocate && deallocator != null) { if (logger.isDebugEnabled()) { logger.debug("Deallocating " + this); @@ -727,7 +728,6 @@ public void deallocate(boolean deallocate) { address = 0; } if (!deallocate || referenceQueue == null) { - DeallocatorReference r = (DeallocatorReference)deallocator; if (r != null) { // remove from queue without calling the deallocator Deallocator d = r.deallocator;