chaokunyang commented on code in PR #2467:
URL: https://github.com/apache/fory/pull/2467#discussion_r2276057539


##########
java/fory-core/src/main/java/org/apache/fory/memory/MemoryBuffer.java:
##########
@@ -2607,6 +2600,59 @@ public String toString() {
         + '}';
   }
 
+  // ------------------------------------------------------------------------
+  // Memory Allocator Support
+  // ------------------------------------------------------------------------
+
+  /** Default memory allocator that uses the original heap-based allocation 
strategy. */
+  private static final class DefaultMemoryAllocator implements MemoryAllocator 
{
+    @Override
+    public MemoryBuffer allocate(int initialSize) {
+      return fromByteArray(new byte[initialSize]);
+    }
+
+    @Override
+    public MemoryBuffer grow(MemoryBuffer buffer, int newCapacity) {
+      if (newCapacity <= buffer.size()) {
+        return buffer;
+      }
+
+      int newSize =
+          newCapacity < BUFFER_GROW_STEP_THRESHOLD
+              ? newCapacity << 2

Review Comment:
   This should be `newCapacity << 1`, the original strategy is too aggressive



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to