You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2022/12/08 18:50:37 UTC

[activemq-artemis] branch main updated: NO-JIRA releaseBufferMemory just in case

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 44cec5976c NO-JIRA releaseBufferMemory just in case
44cec5976c is described below

commit 44cec5976ca0b6933b5a63cf7d46a12fdd537b80
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Dec 8 13:25:40 2022 -0500

    NO-JIRA releaseBufferMemory just in case
    
    This is just to make releaseBuffer to have the same semantic when no pool is used.
    
    This has no effect on how the broker behaves as we always have it pooled.
---
 .../activemq/artemis/core/io/nio/NIOSequentialFileFactory.java      | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFileFactory.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFileFactory.java
index d3c7172fe7..0be3009c13 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFileFactory.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFileFactory.java
@@ -134,7 +134,9 @@ public class NIOSequentialFileFactory extends AbstractSequentialFileFactory {
 
    @Override
    public void releaseDirectBuffer(ByteBuffer buffer) {
-      PlatformDependent.freeDirectBuffer(buffer);
+      if (buffer.isDirect()) {
+         PlatformDependent.freeDirectBuffer(buffer);
+      }
    }
 
    @Override
@@ -155,6 +157,8 @@ public class NIOSequentialFileFactory extends AbstractSequentialFileFactory {
    public void releaseBuffer(ByteBuffer buffer) {
       if (this.bufferPooling) {
          bytesPool.release(buffer);
+      } else {
+         releaseDirectBuffer(buffer);
       }
    }