You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2019/04/17 18:32:47 UTC

[geode] branch feature/GEODE-6662 created (now 65ced0f)

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

bschuchardt pushed a change to branch feature/GEODE-6662
in repository https://gitbox.apache.org/repos/asf/geode.git.


      at 65ced0f  GEODE-6662 NioPlainEngine.ensureWrappedCapacity

This branch includes the following new commits:

     new 65ced0f  GEODE-6662 NioPlainEngine.ensureWrappedCapacity

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[geode] 01/01: GEODE-6662 NioPlainEngine.ensureWrappedCapacity

Posted by bs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a commit to branch feature/GEODE-6662
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 65ced0fb9be22acaa4378677b61a4e3e240bc72c
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Wed Apr 17 11:31:01 2019 -0700

    GEODE-6662 NioPlainEngine.ensureWrappedCapacity
    
    Fixing a memory leak:
    
    Return the old buffer to the Buffers pool after copying its
    contents to a newly allocated buffer.
---
 .../src/main/java/org/apache/geode/internal/net/NioPlainEngine.java | 1 +
 .../test/java/org/apache/geode/internal/net/NioPlainEngineTest.java | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/net/NioPlainEngine.java b/geode-core/src/main/java/org/apache/geode/internal/net/NioPlainEngine.java
index 2c901e6..8a3e3fb 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/net/NioPlainEngine.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/net/NioPlainEngine.java
@@ -76,6 +76,7 @@ public class NioPlainEngine implements NioFilter {
       buffer = Buffers.acquireBuffer(bufferType, amount, stats);
       buffer.clear();
       buffer.put(oldBuffer);
+      Buffers.releaseBuffer(bufferType, oldBuffer, stats);
       lastReadPosition = buffer.position();
       lastProcessedPosition = 0;
     }
diff --git a/geode-core/src/test/java/org/apache/geode/internal/net/NioPlainEngineTest.java b/geode-core/src/test/java/org/apache/geode/internal/net/NioPlainEngineTest.java
index a7eb2d7..3406717 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/net/NioPlainEngineTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/net/NioPlainEngineTest.java
@@ -58,12 +58,14 @@ public class NioPlainEngineTest {
 
   @Test
   public void ensureWrappedCapacity() {
-    ByteBuffer wrappedBuffer = ByteBuffer.allocate(100);
+    ByteBuffer wrappedBuffer = Buffers.acquireReceiveBuffer(100, mockStats);
+    verify(mockStats, times(1)).incReceiverBufferSize(any(Integer.class), any(Boolean.class));
     wrappedBuffer.put(new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
     nioEngine.lastReadPosition = 10;
     int requestedCapacity = 210;
     ByteBuffer result = nioEngine.ensureWrappedCapacity(requestedCapacity, wrappedBuffer,
-        Buffers.BufferType.UNTRACKED, mockStats);
+        Buffers.BufferType.TRACKED_RECEIVER, mockStats);
+    verify(mockStats, times(2)).incReceiverBufferSize(any(Integer.class), any(Boolean.class));
     assertThat(result.capacity()).isGreaterThanOrEqualTo(requestedCapacity);
     assertThat(result).isNotSameAs(wrappedBuffer);
     // make sure that data was transferred to the new buffer