From 9ff69f265dae8f0647fb9c204fda070eafe25613 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 13 Jun 2012 21:05:11 +0000
Subject: [PATCH] Fix OPENDJ-520: Worker threads are too greedy when caching memory used for encoding/decoding entries and protocol messages

---
 opends/src/server/org/opends/server/core/DirectoryServer.java |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index 28c5af7..2ee46ad 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -637,6 +637,10 @@
   // mode is 'manual'.
   private WorkflowElementConfigManager workflowElementConfigManager;
 
+  // The maximum size that internal buffers will be allowed to grow to until
+  // they are trimmed.
+  private int maxInternalBufferSize = DEFAULT_MAX_INTERNAL_BUFFER_SIZE;
+
   /**
    * The default timeout used to start the server in detach mode.
    */
@@ -9968,5 +9972,38 @@
     }
   }
 
+
+
+  /**
+   * Sets the threshold capacity beyond which internal cached buffers used for
+   * encoding and decoding entries and protocol messages will be trimmed after
+   * use.
+   *
+   * @param maxInternalBufferSize
+   *          The threshold capacity beyond which internal cached buffers used
+   *          for encoding and decoding entries and protocol messages will be
+   *          trimmed after use.
+   */
+  public static void setMaxInternalBufferSize(int maxInternalBufferSize)
+  {
+    directoryServer.maxInternalBufferSize = maxInternalBufferSize;
+  }
+
+
+
+  /**
+   * Returns the threshold capacity beyond which internal cached buffers used
+   * for encoding and decoding entries and protocol messages will be trimmed
+   * after use.
+   *
+   * @return The threshold capacity beyond which internal cached buffers used
+   *         for encoding and decoding entries and protocol messages will be
+   *         trimmed after use.
+   */
+  public static int getMaxInternalBufferSize()
+  {
+    return directoryServer.maxInternalBufferSize;
+  }
+
 }
 

--
Gitblit v1.10.0