You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2025/03/07 01:47:51 UTC

(iotdb) branch master updated: Add memory metrics and refact memory allocation (#14710)

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

jiangtian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 23068b42bbe Add memory metrics and refact memory allocation (#14710)
23068b42bbe is described below

commit 23068b42bbe6884f02b684d60b997b964403a03a
Author: ZhangHongYin <46...@users.noreply.github.com>
AuthorDate: Fri Mar 7 09:47:45 2025 +0800

    Add memory metrics and refact memory allocation (#14710)
    
    * fix memory concurrency problem
    
    * add memory related metric name and tag
    
    * add memory threshold code
    
    * add total
    
    * add part of write metrics
    
    * remove hard string code
    
    * fix error code(set storage engine size to schema engine
    
    * degrade metric level
    
    * fix error level
    
    * fix error type and add datanode device path cache
    
    * finish write part
    
    * fix format
    
    * fix name bug
    
    * move buffer pool to memtable
    
    * fix comment
    
    * optimize the code
    
    * add Query Memory Threshold(level=2)
    
    * add Schema Memory Threshold(level=2)
    
    * add Schema Memory Threshold(update comment)
    
    * move Consensus memory threshold
    
    * move Consensus memory threshold
    
    * split class to optimize code
    
    * Add Off Heap Memory Total
    
    * change metric name
    
    * add Metric memory_actual_size
    
    * init first version of memory manager and memory block
    
    * add IIoTDBMemoryBlock
    
    * fix template
    
    * rollback
    
    * rollback 2
    
    * Rename IoTDBRuntimeOutOfMemoryException to IoTDBMemoryException
    
    * Rename IoTDBRuntimeOutOfMemoryException to IoTDBMemoryException
    
    * add version2 memory
    
    * add name of MemoryManager and MemoryBlock
    
    * add global memory manager
    
    * add search memory manager
    
    * add default method to get memory manager
    
    * modify storage engine
    
    * fix
    
    * update
    
    * update
    
    * fix init problem
    
    * fix init problem
    
    * TimePartitionInfo
    
    * Add TimePartitionInfo
    
    * Add Consensus Memory Manager
    
    * Add Pipe Memory Manager
    
    * Add Schema Memory Manager
    
    * add query memory manager
    
    * fix operators memory
    
    * move now into memory manager
    
    * add wal buffer queue size metrics
    
    * remove TestOnly Annotation
    
    * add comment and optimize code
    
    * split off heap
    
    * bug fix
    
    * move compaction into block
    
    * add metric of actual size
    
    * fix tag name
    
    * fix level
    
    * add actural size of memory of memtable
    
    * have a try
    
    * test
    
    * test
    
    * return
    
    * Revert "return"
    
    This reverts commit 16fd24e86ff31fb7261d9942e7a3e93f5dde58da.
    
    * Revert "test"
    
    This reverts commit 36425917d236e816215dd53d2e9236ec95cabb3c.
    
    * Revert "test"
    
    This reverts commit 1a54125b5adba08b4ade9b1cf97d8935cead57fc.
    
    * Revert "have a try"
    
    This reverts commit f1d3e352fdc3fce94cbaee1c689e57d24f43fe12.
    
    * Revert "add actural size of memory of memtable"
    
    This reverts commit 9f974e960dc4837587ab7c938e89a03f9d66b9b8.
    
    * add storage level=4
    
    * fix wait-notify
    
    * fix wait-notify and statistic
    
    * spotless
    
    * init IT test
    
    * avoid notify
    
    * Fix bug in Memory Manager and Memory Block
    
    * Add License
    
    * Empty-Commit
    
    * rollback message in PipeMemoryManager
    
    * fix
    
    * Add some log
    
    * fix reclaim bug
    
    * avoid multi-create
    
    * remove debug log
    
    * fix typo
    
    * Modify TimePartitionMemoryController
    
    * Modify BloomFilterCache Memory Block
    
    * Modify ChunkCache Memory Block
    
    * Modify TimeSeriesMetadataCache Memory Block
    
    * Modify Operators Memory Block
    
    * Modify DataExchange Memory Block
    
    * spotless
    
    * use allocate method
    
    * Modify TimeIndex Memory Block
    
    * Update StorageEngineMemoryMetrics
    
    * Modify Gauge to AutoGauge
    
    * Fix error metric name
    
    * Update StreamEngineMetrics
    
    * Add Consensus Memory Block
    
    * Add Schema Memory Block
    
    * Fix NPE in consensus test
    
    * avoid same name memory block
    
    * Fix return bug in clearAll
    
    * Upgrade Metric Level
    
    * Fix info log
    
    * Fix info log
    
    * Fix concurrent problem
    
    * Fix conflict
    
    * Spotless
    
    * Fix method name
    
    * Fix bug around remove of memory block
    
    * solve all conflict
    
    * add simple auto
    
    * fix format
    
    * Fix start
    
    * Add Log
    
    * Add Memory Service
    
    * Change higher and lower
    
    * Add Config
    
    * Add test log
    
    * Add test log
    
    * Add test log
    
    * Fix auto
    
    * Change higher and lower
    
    * Change higher and lower
    
    * Change higher and lower and add check
    
    * Optimize judge
    
    * Fix pipe bug when merge
    
    * move some manager to memory config
    
    * move some manager to memory config(finish)
    
    * update format
    
    * Fix Agent
    
    * Fix IT
    
    * Fix Symbol
    
    * Fix Format
    
    * Add MemoryBlock UT Test
    
    * Add MemoryBlock UT Test
    
    * Update Auto Logic
    
    * Add Score Method
    
    * Move Logic
    
    * Remove to DataNodeMemoryConfig
    
    * Add Config
    
    * Move into IoTDBDescriptor
    
    * Add RAT
    
    * Change Name
    
    * Add Import
    
    * Add Import
    
    * Add Import
    
    * Fix Format
    
    * Fix Format
    
    * Fix Format
    
    * Fix IT/UT
    
    * Fix Some
    
    * Fix Before
    
    * Add ratio check
    
    * Reset
    
    * Reset and remove
    
    * Reset and remove
    
    * Reset and remove
    
    * Remove
    
    * Rename forceAllocate to exactAllocate
    
    * Rename registerMemoryBlock to getOrCreate
    
    * Update getOrCreateMemoryManager
    
    * Update getOrCreateMemoryManager
    
    * Update Memory Manager
    
    * Fix Log
---
 .../iotdb/consensus/config/IoTConsensusConfig.java |  30 +-
 .../apache/iotdb/consensus/iot/IoTConsensus.java   |   4 +-
 .../logdispatcher/IoTConsensusMemoryManager.java   |  50 +-
 .../apache/iotdb/db/conf/DataNodeMemoryConfig.java | 684 +++++++++++++++++++++
 .../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 345 +----------
 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  | 301 +--------
 .../db/consensus/DataRegionConsensusImpl.java      |  11 +-
 .../db/pipe/resource/memory/PipeMemoryBlock.java   |   2 +-
 .../db/pipe/resource/memory/PipeMemoryManager.java | 100 +--
 .../execution/exchange/SharedTsBlockQueue.java     |   2 +-
 .../execution/exchange/sink/ShuffleSinkHandle.java |   2 +-
 .../execution/exchange/sink/SinkChannel.java       |   2 +-
 .../execution/exchange/source/SourceHandle.java    |   2 +-
 .../execution/memory/LocalMemoryManager.java       |   5 +-
 .../queryengine/execution/memory/MemoryPool.java   |  38 +-
 .../execution/schedule/DriverScheduler.java        |   6 +-
 .../analyze/cache/partition/PartitionCache.java    |  12 +
 .../cache/schema/DataNodeDevicePathCache.java      |  23 +-
 .../plan/planner/LocalExecutionPlanContext.java    |   3 +-
 .../plan/planner/LocalExecutionPlanner.java        | 124 ++--
 .../fetcher/cache/TableDeviceSchemaCache.java      |  15 +-
 .../metric/SchemaEngineCachedMetric.java           |   5 +-
 .../rescon/MemSchemaEngineStatistics.java          |  41 +-
 .../ReleaseFlushStrategySizeBasedImpl.java         |   6 +-
 .../db/service/metrics/CompactionMetrics.java      |   2 +-
 .../iotdb/db/service/metrics/WritingMetrics.java   |   2 +-
 .../metrics/memory/ConsensusMemoryMetrics.java     |  50 +-
 .../metrics/memory/GlobalMemoryMetrics.java        |  82 +--
 .../metrics/memory/OffHeapMemoryMetrics.java       | 102 +++
 .../metrics/memory/QueryEngineMemoryMetrics.java   | 281 ++++++---
 .../metrics/memory/SchemaEngineMemoryMetrics.java  | 159 +++--
 .../metrics/memory/StorageEngineMemoryMetrics.java | 361 +++++++----
 .../metrics/memory/StreamEngineMemoryMetrics.java  |  50 +-
 .../db/storageengine/buffer/BloomFilterCache.java  |  27 +-
 .../iotdb/db/storageengine/buffer/ChunkCache.java  |  27 +-
 .../buffer/TimeSeriesMetadataCache.java            |  27 +-
 .../storageengine/dataregion/DataRegionInfo.java   |   6 +-
 .../wal/utils/MemoryControlledWALEntryQueue.java   |   9 +-
 .../dataregion/wal/utils/WALInsertNodeCache.java   |   5 +-
 .../memory/LoadTsFileAnalyzeSchemaMemoryBlock.java |   2 +-
 .../memory/LoadTsFileDataCacheMemoryBlock.java     |   4 +-
 .../load/memory/LoadTsFileMemoryManager.java       |   2 +-
 .../rescon/memory/PrimitiveArrayManager.java       |  16 +-
 .../db/storageengine/rescon/memory/SystemInfo.java | 187 ++----
 .../rescon/memory/TimePartitionManager.java        |  31 +-
 .../rescon/memory/TsFileResourceManager.java       |  40 +-
 .../execution/exchange/LocalSinkChannelTest.java   |   7 +-
 .../exchange/MPPDataExchangeManagerTest.java       |   7 +-
 .../execution/exchange/SharedTsBlockQueueTest.java |   4 +-
 .../execution/exchange/ShuffleSinkHandleTest.java  |   4 +-
 .../execution/exchange/SinkChannelTest.java        |   7 +-
 .../execution/exchange/SourceHandleTest.java       |  15 +-
 .../execution/memory/MemoryPoolTest.java           |   6 +-
 .../fetcher/cache/TableDeviceSchemaCacheTest.java  |  21 +-
 .../compaction/CompactionWorkerTest.java           |  16 +-
 .../FastCrossCompactionPerformerTest.java          |   5 +-
 .../cross/CrossSpaceCompactionSelectorTest.java    |   5 +-
 .../compaction/utils/CompactionClearUtils.java     |   2 +-
 .../compaction/utils/CompactionTaskQueueTest.java  |  13 +-
 .../rescon/memory/ResourceManagerTest.java         |   6 +-
 .../rescon/memory/TimePartitionManagerTest.java    |   8 +-
 .../apache/iotdb/db/utils/EnvironmentUtils.java    |   5 +-
 .../datastructure/PrimitiveArrayManagerTest.java   |   8 +-
 .../iotdb/commons/concurrent/ThreadName.java       |   1 +
 .../iotdb/commons/conf/CommonDescriptor.java       |   4 +
 .../commons/memory/AtomicLongMemoryBlock.java      | 152 +++++
 .../apache/iotdb/commons/memory/IMemoryBlock.java  | 138 +++++
 .../iotdb/commons/memory/MemoryBlockType.java}     |  29 +-
 .../apache/iotdb/commons/memory/MemoryConfig.java} |  32 +-
 .../iotdb/commons/memory/MemoryException.java      |  64 ++
 .../apache/iotdb/commons/memory/MemoryManager.java | 523 ++++++++++++++++
 .../apache/iotdb/commons/service/ServiceType.java  |   1 +
 .../iotdb/commons/memory/MemoryBlockTest.java      |  67 ++
 .../iotdb/commons/memory/MemoryManagerTest.java    | 171 ++++++
 74 files changed, 3129 insertions(+), 1477 deletions(-)

diff --git a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/config/IoTConsensusConfig.java b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/config/IoTConsensusConfig.java
index 6c89e19291b..0621aee23ef 100644
--- a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/config/IoTConsensusConfig.java
+++ b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/config/IoTConsensusConfig.java
@@ -20,6 +20,8 @@
 package org.apache.iotdb.consensus.config;
 
 import org.apache.iotdb.commons.client.property.ClientPoolProperty.DefaultProperty;
+import org.apache.iotdb.commons.memory.AtomicLongMemoryBlock;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
 
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
@@ -246,8 +248,8 @@ public class IoTConsensusConfig {
     private final long walThrottleThreshold;
     private final long throttleTimeOutMs;
     private final long checkpointGap;
-    private final long allocateMemoryForConsensus;
-    private final long allocateMemoryForQueue;
+    private final IMemoryBlock consensusMemoryBlock;
+    private final double maxMemoryRatioForQueue;
     private final long regionMigrationSpeedLimitBytesPerSecond;
 
     private Replication(
@@ -262,7 +264,7 @@ public class IoTConsensusConfig {
         long walThrottleThreshold,
         long throttleTimeOutMs,
         long checkpointGap,
-        long allocateMemoryForConsensus,
+        IMemoryBlock consensusMemoryBlock,
         double maxMemoryRatioForQueue,
         long regionMigrationSpeedLimitBytesPerSecond) {
       this.maxLogEntriesNumPerBatch = maxLogEntriesNumPerBatch;
@@ -276,8 +278,8 @@ public class IoTConsensusConfig {
       this.walThrottleThreshold = walThrottleThreshold;
       this.throttleTimeOutMs = throttleTimeOutMs;
       this.checkpointGap = checkpointGap;
-      this.allocateMemoryForConsensus = allocateMemoryForConsensus;
-      this.allocateMemoryForQueue = (long) (allocateMemoryForConsensus * maxMemoryRatioForQueue);
+      this.consensusMemoryBlock = consensusMemoryBlock;
+      this.maxMemoryRatioForQueue = maxMemoryRatioForQueue;
       this.regionMigrationSpeedLimitBytesPerSecond = regionMigrationSpeedLimitBytesPerSecond;
     }
 
@@ -325,12 +327,12 @@ public class IoTConsensusConfig {
       return checkpointGap;
     }
 
-    public Long getAllocateMemoryForConsensus() {
-      return allocateMemoryForConsensus;
+    public IMemoryBlock getConsensusMemoryBlock() {
+      return consensusMemoryBlock;
     }
 
-    public long getAllocateMemoryForQueue() {
-      return allocateMemoryForQueue;
+    public double getMaxMemoryRatioForQueue() {
+      return maxMemoryRatioForQueue;
     }
 
     public long getRegionMigrationSpeedLimitBytesPerSecond() {
@@ -355,7 +357,9 @@ public class IoTConsensusConfig {
       private long walThrottleThreshold = 50 * 1024 * 1024 * 1024L;
       private long throttleTimeOutMs = TimeUnit.SECONDS.toMillis(30);
       private long checkpointGap = 500;
-      private long allocateMemoryForConsensus = Runtime.getRuntime().maxMemory() / 10;
+      private IMemoryBlock consensusMemoryBlock =
+          new AtomicLongMemoryBlock(
+              "Consensus-Default", null, Runtime.getRuntime().maxMemory() / 10);
       private double maxMemoryRatioForQueue = 0.6;
       private long regionMigrationSpeedLimitBytesPerSecond = 32 * 1024 * 1024L;
 
@@ -416,8 +420,8 @@ public class IoTConsensusConfig {
         return this;
       }
 
-      public Replication.Builder setAllocateMemoryForConsensus(long allocateMemoryForConsensus) {
-        this.allocateMemoryForConsensus = allocateMemoryForConsensus;
+      public Replication.Builder setConsensusMemoryBlock(IMemoryBlock consensusMemoryBlock) {
+        this.consensusMemoryBlock = consensusMemoryBlock;
         return this;
       }
 
@@ -445,7 +449,7 @@ public class IoTConsensusConfig {
             walThrottleThreshold,
             throttleTimeOutMs,
             checkpointGap,
-            allocateMemoryForConsensus,
+            consensusMemoryBlock,
             maxMemoryRatioForQueue,
             regionMigrationSpeedLimitBytesPerSecond);
       }
diff --git a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensus.java b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensus.java
index 164de58aee9..1ad4170627f 100644
--- a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensus.java
+++ b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensus.java
@@ -125,8 +125,8 @@ public class IoTConsensus implements IConsensus {
     // init IoTConsensus memory manager
     IoTConsensusMemoryManager.getInstance()
         .init(
-            config.getIotConsensusConfig().getReplication().getAllocateMemoryForConsensus(),
-            config.getIotConsensusConfig().getReplication().getAllocateMemoryForQueue());
+            config.getIotConsensusConfig().getReplication().getConsensusMemoryBlock(),
+            config.getIotConsensusConfig().getReplication().getMaxMemoryRatioForQueue());
     // init IoTConsensus Rate Limiter
     IoTConsensusRateLimiter.getInstance()
         .init(
diff --git a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/IoTConsensusMemoryManager.java b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/IoTConsensusMemoryManager.java
index df54918c60e..7bee00588cd 100644
--- a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/IoTConsensusMemoryManager.java
+++ b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/IoTConsensusMemoryManager.java
@@ -19,62 +19,44 @@
 
 package org.apache.iotdb.consensus.iot.logdispatcher;
 
+import org.apache.iotdb.commons.memory.AtomicLongMemoryBlock;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
 import org.apache.iotdb.commons.service.metric.MetricService;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 
 public class IoTConsensusMemoryManager {
   private static final Logger logger = LoggerFactory.getLogger(IoTConsensusMemoryManager.class);
-  private final AtomicLong memorySizeInByte = new AtomicLong(0);
   private final AtomicLong queueMemorySizeInByte = new AtomicLong(0);
   private final AtomicLong syncMemorySizeInByte = new AtomicLong(0);
-  private Long maxMemorySizeInByte = Runtime.getRuntime().maxMemory() / 10;
-  private Long maxMemorySizeForQueueInByte = Runtime.getRuntime().maxMemory() / 100 * 6;
+  private IMemoryBlock memoryBlock =
+      new AtomicLongMemoryBlock("Consensus-Default", null, Runtime.getRuntime().maxMemory() / 10);
+  private Double maxMemoryRatioForQueue = 0.6;
 
   private IoTConsensusMemoryManager() {
     MetricService.getInstance().addMetricSet(new IoTConsensusMemoryManagerMetrics(this));
   }
 
   public boolean reserve(long size, boolean fromQueue) {
-    AtomicBoolean result = new AtomicBoolean(false);
-    memorySizeInByte.updateAndGet(
-        memorySize -> {
-          long remainSize =
-              (fromQueue ? maxMemorySizeForQueueInByte : maxMemorySizeInByte) - memorySize;
-          if (size > remainSize) {
-            logger.debug(
-                "consensus memory limited. required: {}, used: {}, total: {}",
-                size,
-                memorySize,
-                maxMemorySizeInByte);
-            result.set(false);
-            return memorySize;
-          } else {
-            logger.debug(
-                "{} add {} bytes, total memory size: {} bytes.",
-                Thread.currentThread().getName(),
-                size,
-                memorySize + size);
-            result.set(true);
-            return memorySize + size;
-          }
-        });
-    if (result.get()) {
+    boolean result =
+        fromQueue
+            ? memoryBlock.allocateIfSufficient(size, maxMemoryRatioForQueue)
+            : memoryBlock.allocate(size);
+    if (result) {
       if (fromQueue) {
         queueMemorySizeInByte.addAndGet(size);
       } else {
         syncMemorySizeInByte.addAndGet(size);
       }
     }
-    return result.get();
+    return result;
   }
 
   public void free(long size, boolean fromQueue) {
-    long currentUsedMemory = memorySizeInByte.addAndGet(-size);
+    long currentUsedMemory = memoryBlock.release(size);
     if (fromQueue) {
       queueMemorySizeInByte.addAndGet(-size);
     } else {
@@ -87,13 +69,13 @@ public class IoTConsensusMemoryManager {
         currentUsedMemory);
   }
 
-  public void init(long maxMemorySize, long maxMemorySizeForQueue) {
-    this.maxMemorySizeInByte = maxMemorySize;
-    this.maxMemorySizeForQueueInByte = maxMemorySizeForQueue;
+  public void init(IMemoryBlock memoryBlock, double maxMemoryRatioForQueue) {
+    this.memoryBlock = memoryBlock;
+    this.maxMemoryRatioForQueue = maxMemoryRatioForQueue;
   }
 
   long getMemorySizeInByte() {
-    return memorySizeInByte.get();
+    return memoryBlock.getUsedMemoryInBytes();
   }
 
   long getQueueMemorySizeInByte() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/DataNodeMemoryConfig.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/DataNodeMemoryConfig.java
new file mode 100644
index 00000000000..8de17422cc6
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/DataNodeMemoryConfig.java
@@ -0,0 +1,684 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.conf;
+
+import org.apache.iotdb.commons.conf.ConfigurationFileUtils;
+import org.apache.iotdb.commons.conf.TrimProperties;
+import org.apache.iotdb.commons.memory.MemoryConfig;
+import org.apache.iotdb.commons.memory.MemoryManager;
+import org.apache.iotdb.db.utils.MemUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataNodeMemoryConfig {
+  private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeMemoryConfig.class);
+
+  /** Reject proportion for system */
+  private double rejectProportion = 0.8;
+
+  /** The proportion of memtable memory for WAL queue */
+  private double walBufferQueueProportion = 0.1;
+
+  /** The proportion of memtable memory for device path cache */
+  private double devicePathCacheProportion = 0.05;
+
+  /** max total direct buffer off heap memory size proportion */
+  private double maxDirectBufferOffHeapMemorySizeProportion = 0.8;
+
+  /** Ratio of memory allocated for buffered arrays */
+  private double bufferedArraysMemoryProportion = 0.6;
+
+  /**
+   * If true, we will estimate each query's possible memory footprint before executing it and deny
+   * it if its estimated memory exceeds current free memory
+   */
+  private boolean enableQueryMemoryEstimation = true;
+
+  /** whether to cache metadata(ChunkMetaData and TsFileMetaData) or not. */
+  private boolean metaDataCacheEnable = true;
+
+  /** How many threads can concurrently execute query statement. When <= 0, use CPU core number. */
+  private int queryThreadCount = Runtime.getRuntime().availableProcessors();
+
+  /** Max bytes of each FragmentInstance for DataExchange */
+  private long maxBytesPerFragmentInstance =
+      Runtime.getRuntime().maxMemory() * 3 / 10 * 200 / 1001 / queryThreadCount;
+
+  /** The memory manager of on heap */
+  private MemoryManager onHeapMemoryManager;
+
+  /** Memory manager for the write process */
+  private MemoryManager storageEngineMemoryManager;
+
+  /** The memory Manager for write */
+  private MemoryManager writeMemoryManager;
+
+  /** The memory manager for memtable */
+  private MemoryManager memtableMemoryManager;
+
+  /** The memory manager of memtable memory for WAL queue */
+  private MemoryManager walBufferQueueMemoryManager;
+
+  /** The memory manager of memtable memory for device path cache */
+  private MemoryManager devicePathCacheMemoryManager;
+
+  /** The memory manager for buffered arrays */
+  private MemoryManager bufferedArraysMemoryManager;
+
+  /** Memory manager for time partition info */
+  private MemoryManager timePartitionInfoMemoryManager;
+
+  /** The Memory Manager for compaction */
+  private MemoryManager compactionMemoryManager;
+
+  /** Memory manager for the read process */
+  private MemoryManager queryEngineMemoryManager;
+
+  /** Memory manager for bloomFilter cache in read process */
+  private MemoryManager bloomFilterCacheMemoryManager;
+
+  /** Memory manager for timeSeriesMetaData cache in read process */
+  private MemoryManager timeSeriesMetaDataCacheMemoryManager;
+
+  /** Memory manager for chunk cache in read process */
+  private MemoryManager chunkCacheMemoryManager;
+
+  /** Memory manager for coordinator */
+  private MemoryManager coordinatorMemoryManager;
+
+  /** Memory manager for operators */
+  private MemoryManager operatorsMemoryManager;
+
+  /** Memory manager for operators */
+  private MemoryManager dataExchangeMemoryManager;
+
+  /** Memory manager proportion for timeIndex */
+  private MemoryManager timeIndexMemoryManager;
+
+  /** Memory manager for the mtree */
+  private MemoryManager schemaEngineMemoryManager;
+
+  /** Memory manager for schemaRegion */
+  private MemoryManager schemaRegionMemoryManager;
+
+  /** Memory manager for SchemaCache */
+  private MemoryManager schemaCacheMemoryManager;
+
+  /** Memory allocated for PartitionCache */
+  private MemoryManager partitionCacheMemoryManager;
+
+  /** Memory manager for the consensus layer */
+  private MemoryManager consensusMemoryManager;
+
+  /** Memory allocated for the pipe */
+  private MemoryManager pipeMemoryManager;
+
+  /** The memory manager of off heap */
+  private MemoryManager offHeapMemoryManager;
+
+  /** The memory manager of direct Buffer */
+  private MemoryManager directBufferMemoryManager;
+
+  public void init(TrimProperties properties) {
+    // on heap memory
+    String memoryAllocateProportion = properties.getProperty("datanode_memory_proportion", null);
+    // Get global memory manager here
+    if (memoryAllocateProportion == null) {
+      memoryAllocateProportion =
+          properties.getProperty("storage_query_schema_consensus_free_memory_proportion");
+      if (memoryAllocateProportion != null) {
+        LOGGER.warn(
+            "The parameter storage_query_schema_consensus_free_memory_proportion is deprecated since v1.2.3, "
+                + "please use datanode_memory_proportion instead.");
+      }
+    }
+
+    long storageEngineMemorySize = Runtime.getRuntime().maxMemory() * 3 / 10;
+    long queryEngineMemorySize = Runtime.getRuntime().maxMemory() * 3 / 10;
+    long schemaEngineMemorySize = Runtime.getRuntime().maxMemory() / 10;
+    long consensusMemorySize = Runtime.getRuntime().maxMemory() / 10;
+    long pipeMemorySize = Runtime.getRuntime().maxMemory() / 10;
+    if (memoryAllocateProportion != null) {
+      String[] proportions = memoryAllocateProportion.split(":");
+      int proportionSum = 0;
+      for (String proportion : proportions) {
+        proportionSum += Integer.parseInt(proportion.trim());
+      }
+      long maxMemoryAvailable = Runtime.getRuntime().maxMemory();
+
+      if (proportionSum != 0) {
+        storageEngineMemorySize =
+            maxMemoryAvailable * Integer.parseInt(proportions[0].trim()) / proportionSum;
+        queryEngineMemorySize =
+            maxMemoryAvailable * Integer.parseInt(proportions[1].trim()) / proportionSum;
+        schemaEngineMemorySize =
+            maxMemoryAvailable * Integer.parseInt(proportions[2].trim()) / proportionSum;
+        consensusMemorySize =
+            maxMemoryAvailable * Integer.parseInt(proportions[3].trim()) / proportionSum;
+        // if pipe proportion is set, use it, otherwise use the default value
+        if (proportions.length >= 6) {
+          pipeMemorySize =
+              maxMemoryAvailable * Integer.parseInt(proportions[4].trim()) / proportionSum;
+        } else {
+          pipeMemorySize =
+              (maxMemoryAvailable
+                      - storageEngineMemorySize
+                      + queryEngineMemorySize
+                      + schemaEngineMemorySize
+                      + consensusMemorySize)
+                  / 2;
+        }
+      }
+    }
+    onHeapMemoryManager =
+        MemoryConfig.global().getOrCreateMemoryManager("OnHeap", Runtime.getRuntime().maxMemory());
+    storageEngineMemoryManager =
+        onHeapMemoryManager.getOrCreateMemoryManager("StorageEngine", storageEngineMemorySize);
+    queryEngineMemoryManager =
+        onHeapMemoryManager.getOrCreateMemoryManager("QueryEngine", queryEngineMemorySize);
+    schemaEngineMemoryManager =
+        onHeapMemoryManager.getOrCreateMemoryManager("SchemaEngine", schemaEngineMemorySize);
+    consensusMemoryManager =
+        onHeapMemoryManager.getOrCreateMemoryManager("Consensus", consensusMemorySize);
+    pipeMemoryManager = onHeapMemoryManager.getOrCreateMemoryManager("Pipe", pipeMemorySize);
+    LOGGER.info(
+        "initial allocateMemoryForWrite = {}",
+        storageEngineMemoryManager.getTotalMemorySizeInBytes());
+    LOGGER.info(
+        "initial allocateMemoryForRead = {}", queryEngineMemoryManager.getTotalMemorySizeInBytes());
+    LOGGER.info(
+        "initial allocateMemoryForSchema = {}",
+        schemaEngineMemoryManager.getTotalMemorySizeInBytes());
+    LOGGER.info(
+        "initial allocateMemoryForConsensus = {}",
+        consensusMemoryManager.getTotalMemorySizeInBytes());
+    LOGGER.info(
+        "initial allocateMemoryForPipe = {}", pipeMemoryManager.getTotalMemorySizeInBytes());
+
+    initSchemaMemoryAllocate(schemaEngineMemoryManager, properties);
+    initStorageEngineAllocate(storageEngineMemoryManager, properties);
+    initQueryEngineMemoryAllocate(queryEngineMemoryManager, properties);
+
+    String offHeapMemoryStr = System.getProperty("OFF_HEAP_MEMORY");
+    offHeapMemoryManager =
+        MemoryConfig.global()
+            .getOrCreateMemoryManager("OffHeap", MemUtils.strToBytesCnt(offHeapMemoryStr), false);
+
+    // when we can't get the OffHeapMemory variable from environment, it will be 0
+    // and the limit should not be effective
+    long totalDirectBufferMemorySizeLimit =
+        offHeapMemoryManager.getTotalMemorySizeInBytes() == 0
+            ? Long.MAX_VALUE
+            : (long)
+                (offHeapMemoryManager.getTotalMemorySizeInBytes()
+                    * getMaxDirectBufferOffHeapMemorySizeProportion());
+    directBufferMemoryManager =
+        offHeapMemoryManager.getOrCreateMemoryManager(
+            "DirectBuffer", totalDirectBufferMemorySizeLimit);
+  }
+
+  @SuppressWarnings("squid:S3518")
+  private void initSchemaMemoryAllocate(
+      MemoryManager schemaEngineMemoryManager, TrimProperties properties) {
+    long schemaMemoryTotal = schemaEngineMemoryManager.getTotalMemorySizeInBytes();
+    int[] schemaMemoryProportion = new int[] {5, 4, 1};
+    String schemaMemoryPortionInput =
+        properties.getProperty(
+            "schema_memory_proportion",
+            properties.getProperty("schema_memory_allocate_proportion"));
+    if (schemaMemoryPortionInput != null) {
+      String[] proportions = schemaMemoryPortionInput.split(":");
+      int loadedProportionSum = 0;
+      for (String proportion : proportions) {
+        loadedProportionSum += Integer.parseInt(proportion.trim());
+      }
+
+      if (loadedProportionSum != 0) {
+        for (int i = 0; i < schemaMemoryProportion.length; i++) {
+          schemaMemoryProportion[i] = Integer.parseInt(proportions[i].trim());
+        }
+      }
+    }
+
+    int proportionSum = 0;
+    for (int proportion : schemaMemoryProportion) {
+      proportionSum += proportion;
+    }
+
+    schemaRegionMemoryManager =
+        schemaEngineMemoryManager.getOrCreateMemoryManager(
+            "SchemaRegion", schemaMemoryTotal * schemaMemoryProportion[0] / proportionSum);
+    schemaCacheMemoryManager =
+        schemaEngineMemoryManager.getOrCreateMemoryManager(
+            "SchemaCache", schemaMemoryTotal * schemaMemoryProportion[1] / proportionSum);
+    partitionCacheMemoryManager =
+        schemaEngineMemoryManager.getOrCreateMemoryManager(
+            "PartitionCache", schemaMemoryTotal * schemaMemoryProportion[2] / proportionSum);
+
+    LOGGER.info(
+        "allocateMemoryForSchemaRegion = {}",
+        schemaRegionMemoryManager.getTotalMemorySizeInBytes());
+    LOGGER.info(
+        "allocateMemoryForSchemaCache = {}", schemaCacheMemoryManager.getTotalMemorySizeInBytes());
+    LOGGER.info(
+        "allocateMemoryForPartitionCache = {}",
+        partitionCacheMemoryManager.getTotalMemorySizeInBytes());
+  }
+
+  @SuppressWarnings("java:S3518")
+  private void initStorageEngineAllocate(
+      MemoryManager storageEngineMemoryManager, TrimProperties properties) {
+    final double rejectProportion =
+        Double.parseDouble(
+            properties.getProperty("reject_proportion", Double.toString(getRejectProportion())));
+    final double walBufferQueueProportion =
+        Double.parseDouble(
+            properties.getProperty(
+                "wal_buffer_queue_proportion", Double.toString(getWalBufferQueueProportion())));
+    final double devicePathCacheProportion =
+        Double.parseDouble(
+            properties.getProperty(
+                "device_path_cache_proportion", Double.toString(getDevicePathCacheProportion())));
+
+    if (rejectProportion + walBufferQueueProportion + devicePathCacheProportion >= 1) {
+      LOGGER.warn(
+          "The sum of reject_proportion, wal_buffer_queue_proportion and device_path_cache_proportion is too large, use default values 0.8, 0.1 and 0.05.");
+    } else {
+      setRejectProportion(rejectProportion);
+      setWalBufferQueueProportion(walBufferQueueProportion);
+      setDevicePathCacheProportion(devicePathCacheProportion);
+    }
+
+    setBufferedArraysMemoryProportion(
+        Double.parseDouble(
+            properties.getProperty(
+                "buffered_arrays_memory_proportion",
+                Double.toString(getBufferedArraysMemoryProportion()))));
+
+    long storageMemoryTotal = storageEngineMemoryManager.getTotalMemorySizeInBytes();
+    String valueOfStorageEngineMemoryProportion =
+        properties.getProperty("storage_engine_memory_proportion");
+    long writeMemorySize = storageMemoryTotal * 8 / 10;
+    long compactionMemorySize = storageMemoryTotal * 2 / 10;
+    long memtableMemorySize = writeMemorySize * 19 / 20;
+    long timePartitionInfoMemorySize = writeMemorySize / 20;
+    if (valueOfStorageEngineMemoryProportion != null) {
+      String[] storageProportionArray = valueOfStorageEngineMemoryProportion.split(":");
+      int storageEngineMemoryProportion = 0;
+      for (String proportion : storageProportionArray) {
+        int proportionValue = Integer.parseInt(proportion.trim());
+        if (proportionValue <= 0) {
+          LOGGER.warn(
+              "The value of storage_engine_memory_proportion is illegal, use default value 8:2 .");
+          return;
+        }
+        storageEngineMemoryProportion += proportionValue;
+      }
+      writeMemorySize =
+          storageMemoryTotal
+              * Integer.parseInt(storageProportionArray[0].trim())
+              / storageEngineMemoryProportion;
+      compactionMemorySize =
+          storageMemoryTotal
+              * Integer.parseInt(storageProportionArray[1].trim())
+              / storageEngineMemoryProportion;
+
+      String valueOfWriteMemoryProportion = properties.getProperty("write_memory_proportion");
+      if (valueOfWriteMemoryProportion != null) {
+        String[] writeProportionArray = valueOfWriteMemoryProportion.split(":");
+        int writeMemoryProportion = 0;
+        for (String proportion : writeProportionArray) {
+          int proportionValue = Integer.parseInt(proportion.trim());
+          writeMemoryProportion += proportionValue;
+          if (proportionValue <= 0) {
+            LOGGER.warn(
+                "The value of write_memory_proportion is illegal, use default value 19:1 .");
+            return;
+          }
+        }
+
+        memtableMemorySize =
+            writeMemorySize
+                * Integer.parseInt(writeProportionArray[0].trim())
+                / writeMemoryProportion;
+        timePartitionInfoMemorySize =
+            writeMemorySize
+                * Integer.parseInt(writeProportionArray[1].trim())
+                / writeMemoryProportion;
+      }
+    }
+    writeMemoryManager =
+        storageEngineMemoryManager.getOrCreateMemoryManager("Write", writeMemorySize);
+    compactionMemoryManager =
+        storageEngineMemoryManager.getOrCreateMemoryManager("Compaction", compactionMemorySize);
+    memtableMemoryManager =
+        writeMemoryManager.getOrCreateMemoryManager("Memtable", memtableMemorySize);
+    timePartitionInfoMemoryManager =
+        writeMemoryManager.getOrCreateMemoryManager(
+            "TimePartitionInfo", timePartitionInfoMemorySize);
+    long devicePathCacheMemorySize = (long) (memtableMemorySize * getDevicePathCacheProportion());
+    devicePathCacheMemoryManager =
+        memtableMemoryManager.getOrCreateMemoryManager(
+            "DevicePathCache", devicePathCacheMemorySize);
+    long bufferedArraysMemorySize =
+        (long) (storageMemoryTotal * getBufferedArraysMemoryProportion());
+    bufferedArraysMemoryManager =
+        memtableMemoryManager.getOrCreateMemoryManager("BufferedArray", bufferedArraysMemorySize);
+    long walBufferQueueMemorySize = (long) (memtableMemorySize * getWalBufferQueueProportion());
+    walBufferQueueMemoryManager =
+        memtableMemoryManager.getOrCreateMemoryManager("WalBufferQueue", walBufferQueueMemorySize);
+  }
+
+  @SuppressWarnings("squid:S3518")
+  private void initQueryEngineMemoryAllocate(
+      MemoryManager queryEngineMemoryManager, TrimProperties properties) {
+    setEnableQueryMemoryEstimation(
+        Boolean.parseBoolean(
+            properties.getProperty(
+                "enable_query_memory_estimation",
+                Boolean.toString(isEnableQueryMemoryEstimation()))));
+    setMetaDataCacheEnable(
+        Boolean.parseBoolean(
+            properties.getProperty(
+                "meta_data_cache_enable", Boolean.toString(isMetaDataCacheEnable()))));
+    setQueryThreadCount(
+        Integer.parseInt(
+            properties.getProperty("query_thread_count", Integer.toString(getQueryThreadCount()))));
+
+    if (getQueryThreadCount() <= 0) {
+      setQueryThreadCount(Runtime.getRuntime().availableProcessors());
+    }
+    try {
+      // update enable query memory estimation for memory control
+      setEnableQueryMemoryEstimation(
+          Boolean.parseBoolean(
+              properties.getProperty(
+                  "enable_query_memory_estimation",
+                  ConfigurationFileUtils.getConfigurationDefaultValue(
+                      "enable_query_memory_estimation"))));
+
+    } catch (Exception e) {
+      LOGGER.error(String.format("Fail to reload configuration because %s", e));
+    }
+
+    String queryMemoryAllocateProportion =
+        properties.getProperty("chunk_timeseriesmeta_free_memory_proportion");
+    long maxMemoryAvailable = queryEngineMemoryManager.getTotalMemorySizeInBytes();
+
+    long bloomFilterCacheMemorySize = maxMemoryAvailable / 1001;
+    long chunkCacheMemorySize = maxMemoryAvailable * 100 / 1001;
+    long timeSeriesMetaDataCacheMemorySize = maxMemoryAvailable * 200 / 1001;
+    long coordinatorMemorySize = maxMemoryAvailable * 50 / 1001;
+    long operatorsMemorySize = maxMemoryAvailable * 200 / 1001;
+    long dataExchangeMemorySize = maxMemoryAvailable * 200 / 1001;
+    long timeIndexMemorySize = maxMemoryAvailable * 200 / 1001;
+    if (queryMemoryAllocateProportion != null) {
+      String[] proportions = queryMemoryAllocateProportion.split(":");
+      int proportionSum = 0;
+      for (String proportion : proportions) {
+        proportionSum += Integer.parseInt(proportion.trim());
+      }
+      if (proportionSum != 0) {
+        try {
+          bloomFilterCacheMemorySize =
+              maxMemoryAvailable * Integer.parseInt(proportions[0].trim()) / proportionSum;
+          chunkCacheMemorySize =
+              maxMemoryAvailable * Integer.parseInt(proportions[1].trim()) / proportionSum;
+          timeSeriesMetaDataCacheMemorySize =
+              maxMemoryAvailable * Integer.parseInt(proportions[2].trim()) / proportionSum;
+          coordinatorMemorySize =
+              maxMemoryAvailable * Integer.parseInt(proportions[3].trim()) / proportionSum;
+          operatorsMemorySize =
+              maxMemoryAvailable * Integer.parseInt(proportions[4].trim()) / proportionSum;
+          dataExchangeMemorySize =
+              maxMemoryAvailable * Integer.parseInt(proportions[5].trim()) / proportionSum;
+          timeIndexMemorySize =
+              maxMemoryAvailable * Integer.parseInt(proportions[6].trim()) / proportionSum;
+        } catch (Exception e) {
+          throw new IllegalArgumentException(
+              "Each subsection of configuration item chunkmeta_chunk_timeseriesmeta_free_memory_proportion"
+                  + " should be an integer, which is "
+                  + queryMemoryAllocateProportion,
+              e);
+        }
+      }
+    }
+
+    // metadata cache is disabled, we need to move all their allocated memory to other parts
+    if (!isMetaDataCacheEnable()) {
+      long sum =
+          bloomFilterCacheMemoryManager.getTotalMemorySizeInBytes()
+              + chunkCacheMemoryManager.getTotalMemorySizeInBytes()
+              + timeSeriesMetaDataCacheMemoryManager.getTotalMemorySizeInBytes();
+      bloomFilterCacheMemorySize = 0;
+      chunkCacheMemorySize = 0;
+      timeSeriesMetaDataCacheMemorySize = 0;
+      long partForDataExchange = sum / 2;
+      long partForOperators = sum - partForDataExchange;
+      dataExchangeMemorySize += partForDataExchange;
+      operatorsMemorySize += partForOperators;
+    }
+    // set max bytes per fragment instance
+    setMaxBytesPerFragmentInstance(dataExchangeMemorySize / getQueryThreadCount());
+
+    bloomFilterCacheMemoryManager =
+        queryEngineMemoryManager.getOrCreateMemoryManager(
+            "BloomFilterCache", bloomFilterCacheMemorySize);
+    chunkCacheMemoryManager =
+        queryEngineMemoryManager.getOrCreateMemoryManager("ChunkCache", chunkCacheMemorySize);
+    timeSeriesMetaDataCacheMemoryManager =
+        queryEngineMemoryManager.getOrCreateMemoryManager(
+            "TimeSeriesMetaDataCache", timeSeriesMetaDataCacheMemorySize);
+    coordinatorMemoryManager =
+        queryEngineMemoryManager.getOrCreateMemoryManager("Coordinator", coordinatorMemorySize);
+    operatorsMemoryManager =
+        queryEngineMemoryManager.getOrCreateMemoryManager("Operators", operatorsMemorySize);
+    dataExchangeMemoryManager =
+        queryEngineMemoryManager.getOrCreateMemoryManager("DataExchange", dataExchangeMemorySize);
+    timeIndexMemoryManager =
+        queryEngineMemoryManager.getOrCreateMemoryManager("TimeIndex", timeIndexMemorySize);
+  }
+
+  public double getRejectProportion() {
+    return rejectProportion;
+  }
+
+  public void setRejectProportion(double rejectProportion) {
+    this.rejectProportion = rejectProportion;
+  }
+
+  public double getWalBufferQueueProportion() {
+    return walBufferQueueProportion;
+  }
+
+  public void setWalBufferQueueProportion(double walBufferQueueProportion) {
+    this.walBufferQueueProportion = walBufferQueueProportion;
+  }
+
+  public double getMaxDirectBufferOffHeapMemorySizeProportion() {
+    return maxDirectBufferOffHeapMemorySizeProportion;
+  }
+
+  public void setMaxDirectBufferOffHeapMemorySizeProportion(
+      double maxDirectBufferOffHeapMemorySizeProportion) {
+    this.maxDirectBufferOffHeapMemorySizeProportion = maxDirectBufferOffHeapMemorySizeProportion;
+  }
+
+  public double getBufferedArraysMemoryProportion() {
+    return bufferedArraysMemoryProportion;
+  }
+
+  public void setBufferedArraysMemoryProportion(double bufferedArraysMemoryProportion) {
+    this.bufferedArraysMemoryProportion = bufferedArraysMemoryProportion;
+  }
+
+  public double getDevicePathCacheProportion() {
+    return devicePathCacheProportion;
+  }
+
+  public void setDevicePathCacheProportion(double devicePathCacheProportion) {
+    this.devicePathCacheProportion = devicePathCacheProportion;
+  }
+
+  public boolean isEnableQueryMemoryEstimation() {
+    return enableQueryMemoryEstimation;
+  }
+
+  public void setEnableQueryMemoryEstimation(boolean enableQueryMemoryEstimation) {
+    this.enableQueryMemoryEstimation = enableQueryMemoryEstimation;
+  }
+
+  public boolean isMetaDataCacheEnable() {
+    return metaDataCacheEnable;
+  }
+
+  public void setMetaDataCacheEnable(boolean metaDataCacheEnable) {
+    this.metaDataCacheEnable = metaDataCacheEnable;
+  }
+
+  public int getQueryThreadCount() {
+    return queryThreadCount;
+  }
+
+  public void setQueryThreadCount(int queryThreadCount) {
+    if (queryThreadCount <= 0) {
+      queryThreadCount = Runtime.getRuntime().availableProcessors();
+    }
+    this.queryThreadCount = queryThreadCount;
+    // TODO @spricoder: influence dynamic change of memory size
+    if (getDataExchangeMemoryManager() != null) {
+      this.maxBytesPerFragmentInstance =
+          getDataExchangeMemoryManager().getTotalMemorySizeInBytes() / queryThreadCount;
+    }
+  }
+
+  public long getMaxBytesPerFragmentInstance() {
+    return maxBytesPerFragmentInstance;
+  }
+
+  public void setMaxBytesPerFragmentInstance(long maxBytesPerFragmentInstance) {
+    this.maxBytesPerFragmentInstance = maxBytesPerFragmentInstance;
+  }
+
+  public MemoryManager getOnHeapMemoryManager() {
+    return onHeapMemoryManager;
+  }
+
+  public MemoryManager getStorageEngineMemoryManager() {
+    return storageEngineMemoryManager;
+  }
+
+  public MemoryManager getWriteMemoryManager() {
+    return writeMemoryManager;
+  }
+
+  public MemoryManager getMemtableMemoryManager() {
+    return memtableMemoryManager;
+  }
+
+  public MemoryManager getWalBufferQueueMemoryManager() {
+    return walBufferQueueMemoryManager;
+  }
+
+  public MemoryManager getDevicePathCacheMemoryManager() {
+    return devicePathCacheMemoryManager;
+  }
+
+  public MemoryManager getBufferedArraysMemoryManager() {
+    return bufferedArraysMemoryManager;
+  }
+
+  public MemoryManager getTimePartitionInfoMemoryManager() {
+    return timePartitionInfoMemoryManager;
+  }
+
+  public MemoryManager getCompactionMemoryManager() {
+    return compactionMemoryManager;
+  }
+
+  public MemoryManager getQueryEngineMemoryManager() {
+    return queryEngineMemoryManager;
+  }
+
+  public MemoryManager getBloomFilterCacheMemoryManager() {
+    return bloomFilterCacheMemoryManager;
+  }
+
+  public MemoryManager getTimeSeriesMetaDataCacheMemoryManager() {
+    return timeSeriesMetaDataCacheMemoryManager;
+  }
+
+  public MemoryManager getChunkCacheMemoryManager() {
+    return chunkCacheMemoryManager;
+  }
+
+  public MemoryManager getCoordinatorMemoryManager() {
+    return coordinatorMemoryManager;
+  }
+
+  public MemoryManager getOperatorsMemoryManager() {
+    return operatorsMemoryManager;
+  }
+
+  public MemoryManager getDataExchangeMemoryManager() {
+    return dataExchangeMemoryManager;
+  }
+
+  public MemoryManager getTimeIndexMemoryManager() {
+    return timeIndexMemoryManager;
+  }
+
+  public MemoryManager getSchemaEngineMemoryManager() {
+    return schemaEngineMemoryManager;
+  }
+
+  public MemoryManager getSchemaRegionMemoryManager() {
+    return schemaRegionMemoryManager;
+  }
+
+  public MemoryManager getSchemaCacheMemoryManager() {
+    return schemaCacheMemoryManager;
+  }
+
+  public void setSchemaCacheMemoryManager(MemoryManager schemaCacheMemoryManager) {
+    this.schemaCacheMemoryManager = schemaCacheMemoryManager;
+  }
+
+  public MemoryManager getPartitionCacheMemoryManager() {
+    return partitionCacheMemoryManager;
+  }
+
+  public MemoryManager getConsensusMemoryManager() {
+    return consensusMemoryManager;
+  }
+
+  public MemoryManager getPipeMemoryManager() {
+    return pipeMemoryManager;
+  }
+
+  public MemoryManager getOffHeapMemoryManager() {
+    return offHeapMemoryManager;
+  }
+
+  public MemoryManager getDirectBufferMemoryManager() {
+    return directBufferMemoryManager;
+  }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 72264ef26f7..41b3c6a0fa3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -25,7 +25,6 @@ import org.apache.iotdb.commons.client.property.ClientPoolProperty.DefaultProper
 import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.commons.utils.FileUtils;
-import org.apache.iotdb.commons.utils.TestOnly;
 import org.apache.iotdb.consensus.ConsensusFactory;
 import org.apache.iotdb.db.audit.AuditLogOperation;
 import org.apache.iotdb.db.audit.AuditLogStorage;
@@ -151,46 +150,15 @@ public class IoTDBConfig {
   /** Max concurrent client number */
   private int rpcMaxConcurrentClientNum = 65535;
 
-  /** Memory allocated for the write process */
-  private long allocateMemoryForStorageEngine = Runtime.getRuntime().maxMemory() * 3 / 10;
-
-  /** Memory allocated for the read process */
   private long allocateMemoryForRead = Runtime.getRuntime().maxMemory() * 3 / 10;
 
-  /** Memory allocated for the mtree */
-  private long allocateMemoryForSchema = Runtime.getRuntime().maxMemory() / 10;
-
-  /** Memory allocated for the consensus layer */
-  private long allocateMemoryForConsensus = Runtime.getRuntime().maxMemory() / 10;
-
-  /** Memory allocated for the pipe */
-  private long allocateMemoryForPipe = Runtime.getRuntime().maxMemory() / 10;
-
-  /** Ratio of memory allocated for buffered arrays */
-  private double bufferedArraysMemoryProportion = 0.6;
-
   /** Flush proportion for system */
   private double flushProportion = 0.4;
 
-  /** Reject proportion for system */
-  private double rejectProportion = 0.8;
-
-  /** The proportion of write memory for memtable */
-  private double writeProportionForMemtable = 0.76;
-
-  /** The proportion of write memory for compaction */
-  private double compactionProportion = 0.2;
-
-  /** The proportion of memtable memory for WAL queue */
-  private double walBufferQueueProportion = 0.1;
-
-  /** The proportion of memtable memory for device path cache */
-  private double devicePathCacheProportion = 0.05;
-
   /**
    * If memory cost of data region increased more than proportion of {@linkplain
-   * IoTDBConfig#getAllocateMemoryForStorageEngine()}*{@linkplain
-   * IoTDBConfig#getWriteProportionForMemtable()}, report to system.
+   * DataNodeMemoryConfig#getStorageEngineMemoryManager()} *{@linkplain
+   * DataNodeMemoryConfig#getMemtableMemoryManager()}, report to system.
    */
   private double writeMemoryVariationReportProportion = 0.001;
 
@@ -200,9 +168,6 @@ public class IoTDBConfig {
   /** When inserting rejected exceeds this, throw an exception. Unit: millisecond */
   private int maxWaitingTimeWhenInsertBlockedInMs = 10000;
 
-  /** off heap memory bytes from env */
-  private long maxOffHeapMemoryBytes = 0;
-
   // region Write Ahead Log Configuration
   /** Write mode of wal */
   private volatile WALMode walMode = WALMode.ASYNC;
@@ -225,9 +190,6 @@ public class IoTDBConfig {
   /** Buffer size of each wal node. Unit: byte */
   private int walBufferSize = 32 * 1024 * 1024;
 
-  /** max total direct buffer off heap memory size proportion */
-  private double maxDirectBufferOffHeapMemorySizeProportion = 0.8;
-
   /** Blocking queue capacity of each delete ahead log buffer */
   private int deletionAheadLogBufferQueueCapacity = 500;
 
@@ -367,9 +329,6 @@ public class IoTDBConfig {
   /** How many threads can concurrently flush. When <= 0, use CPU core number. */
   private int flushThreadCount = Runtime.getRuntime().availableProcessors();
 
-  /** How many threads can concurrently execute query statement. When <= 0, use CPU core number. */
-  private int queryThreadCount = Runtime.getRuntime().availableProcessors();
-
   private int degreeOfParallelism = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
 
   private int mergeThresholdOfExplainAnalyze = 10;
@@ -593,42 +552,6 @@ public class IoTDBConfig {
   /** The size of global compaction estimation file info cahce. */
   private int globalCompactionFileInfoCacheSize = 1000;
 
-  /** whether to cache meta data(ChunkMetaData and TsFileMetaData) or not. */
-  private boolean metaDataCacheEnable = true;
-
-  /** Memory allocated for bloomFilter cache in read process */
-  private long allocateMemoryForBloomFilterCache = allocateMemoryForRead / 1001;
-
-  /** Memory allocated for timeSeriesMetaData cache in read process */
-  private long allocateMemoryForTimeSeriesMetaDataCache = allocateMemoryForRead * 200 / 1001;
-
-  /** Memory allocated for chunk cache in read process */
-  private long allocateMemoryForChunkCache = allocateMemoryForRead * 100 / 1001;
-
-  /** Memory allocated for operators */
-  private long allocateMemoryForCoordinator = allocateMemoryForRead * 50 / 1001;
-
-  /** Memory allocated for operators */
-  private long allocateMemoryForOperators = allocateMemoryForRead * 200 / 1001;
-
-  /** Memory allocated for operators */
-  private long allocateMemoryForDataExchange = allocateMemoryForRead * 200 / 1001;
-
-  /** Max bytes of each FragmentInstance for DataExchange */
-  private long maxBytesPerFragmentInstance = allocateMemoryForDataExchange / queryThreadCount;
-
-  /** Memory allocated proportion for timeIndex */
-  private long allocateMemoryForTimeIndex = allocateMemoryForRead * 200 / 1001;
-
-  /** Memory allocated proportion for time partition info */
-  private long allocateMemoryForTimePartitionInfo = allocateMemoryForStorageEngine * 8 / 10 / 20;
-
-  /**
-   * If true, we will estimate each query's possible memory footprint before executing it and deny
-   * it if its estimated memory exceeds current free memory
-   */
-  private boolean enableQueryMemoryEstimation = true;
-
   /** Cache size of {@code checkAndGetDataTypeCache}. */
   private int mRemoteSchemaCacheSize = 100000;
 
@@ -1037,17 +960,6 @@ public class IoTDBConfig {
   /** ThreadPool size for write operation in coordinator */
   private int coordinatorWriteExecutorSize = 50;
 
-  private int[] schemaMemoryProportion = new int[] {5, 4, 1};
-
-  /** Memory allocated for schemaRegion */
-  private long allocateMemoryForSchemaRegion = allocateMemoryForSchema * 5 / 10;
-
-  /** Memory allocated for SchemaCache */
-  private long allocateMemoryForSchemaCache = allocateMemoryForSchema * 4 / 10;
-
-  /** Memory allocated for PartitionCache */
-  private long allocateMemoryForPartitionCache = allocateMemoryForSchema / 10;
-
   /** Policy of DataNodeSchemaCache eviction */
   private String dataNodeSchemaCacheEvictionPolicy = "FIFO";
 
@@ -1782,18 +1694,6 @@ public class IoTDBConfig {
     this.flushThreadCount = flushThreadCount;
   }
 
-  public int getQueryThreadCount() {
-    return queryThreadCount;
-  }
-
-  public void setQueryThreadCount(int queryThreadCount) {
-    if (queryThreadCount <= 0) {
-      queryThreadCount = Runtime.getRuntime().availableProcessors();
-    }
-    this.queryThreadCount = queryThreadCount;
-    this.maxBytesPerFragmentInstance = allocateMemoryForDataExchange / queryThreadCount;
-  }
-
   public void setDegreeOfParallelism(int degreeOfParallelism) {
     if (degreeOfParallelism > 0) {
       this.degreeOfParallelism = degreeOfParallelism;
@@ -1820,15 +1720,6 @@ public class IoTDBConfig {
     this.maxAllowedConcurrentQueries = maxAllowedConcurrentQueries;
   }
 
-  public long getMaxBytesPerFragmentInstance() {
-    return maxBytesPerFragmentInstance;
-  }
-
-  @TestOnly
-  public void setMaxBytesPerFragmentInstance(long maxBytesPerFragmentInstance) {
-    this.maxBytesPerFragmentInstance = maxBytesPerFragmentInstance;
-  }
-
   public int getWindowEvaluationThreadCount() {
     return windowEvaluationThreadCount;
   }
@@ -1987,15 +1878,6 @@ public class IoTDBConfig {
     this.walBufferSize = walBufferSize;
   }
 
-  public double getMaxDirectBufferOffHeapMemorySizeProportion() {
-    return maxDirectBufferOffHeapMemorySizeProportion;
-  }
-
-  public void setMaxDirectBufferOffHeapMemorySizeProportion(
-      double maxDirectBufferOffHeapMemorySizeProportion) {
-    this.maxDirectBufferOffHeapMemorySizeProportion = maxDirectBufferOffHeapMemorySizeProportion;
-  }
-
   public int getDeletionAheadLogBufferQueueCapacity() {
     return deletionAheadLogBufferQueueCapacity;
   }
@@ -2076,14 +1958,6 @@ public class IoTDBConfig {
     this.mergeIntervalSec = mergeIntervalSec;
   }
 
-  public double getBufferedArraysMemoryProportion() {
-    return bufferedArraysMemoryProportion;
-  }
-
-  public void setBufferedArraysMemoryProportion(double bufferedArraysMemoryProportion) {
-    this.bufferedArraysMemoryProportion = bufferedArraysMemoryProportion;
-  }
-
   public double getFlushProportion() {
     return flushProportion;
   }
@@ -2092,14 +1966,6 @@ public class IoTDBConfig {
     this.flushProportion = flushProportion;
   }
 
-  public double getRejectProportion() {
-    return rejectProportion;
-  }
-
-  public void setRejectProportion(double rejectProportion) {
-    this.rejectProportion = rejectProportion;
-  }
-
   public double getWriteMemoryVariationReportProportion() {
     return writeMemoryVariationReportProportion;
   }
@@ -2108,59 +1974,6 @@ public class IoTDBConfig {
     this.writeMemoryVariationReportProportion = writeMemoryVariationReportProportion;
   }
 
-  public long getAllocateMemoryForStorageEngine() {
-    return allocateMemoryForStorageEngine;
-  }
-
-  public void setAllocateMemoryForStorageEngine(long allocateMemoryForStorageEngine) {
-    this.allocateMemoryForStorageEngine = allocateMemoryForStorageEngine;
-  }
-
-  public long getAllocateMemoryForSchema() {
-    return allocateMemoryForSchema;
-  }
-
-  public void setAllocateMemoryForSchema(long allocateMemoryForSchema) {
-    this.allocateMemoryForSchema = allocateMemoryForSchema;
-
-    this.allocateMemoryForSchemaRegion = allocateMemoryForSchema * 5 / 10;
-    this.allocateMemoryForSchemaCache = allocateMemoryForSchema * 4 / 10;
-    this.allocateMemoryForPartitionCache = allocateMemoryForSchema / 10;
-  }
-
-  public long getAllocateMemoryForConsensus() {
-    return allocateMemoryForConsensus;
-  }
-
-  public void setAllocateMemoryForConsensus(long allocateMemoryForConsensus) {
-    this.allocateMemoryForConsensus = allocateMemoryForConsensus;
-  }
-
-  public long getAllocateMemoryForRead() {
-    return allocateMemoryForRead;
-  }
-
-  void setAllocateMemoryForRead(long allocateMemoryForRead) {
-    this.allocateMemoryForRead = allocateMemoryForRead;
-
-    this.allocateMemoryForBloomFilterCache = allocateMemoryForRead / 1001;
-    this.allocateMemoryForTimeSeriesMetaDataCache = allocateMemoryForRead * 200 / 1001;
-    this.allocateMemoryForChunkCache = allocateMemoryForRead * 100 / 1001;
-    this.allocateMemoryForCoordinator = allocateMemoryForRead * 50 / 1001;
-    this.allocateMemoryForOperators = allocateMemoryForRead * 200 / 1001;
-    this.allocateMemoryForDataExchange = allocateMemoryForRead * 200 / 1001;
-    this.maxBytesPerFragmentInstance = allocateMemoryForDataExchange / queryThreadCount;
-    this.allocateMemoryForTimeIndex = allocateMemoryForRead * 200 / 1001;
-  }
-
-  public long getAllocateMemoryForPipe() {
-    return allocateMemoryForPipe;
-  }
-
-  public void setAllocateMemoryForPipe(long allocateMemoryForPipe) {
-    this.allocateMemoryForPipe = allocateMemoryForPipe;
-  }
-
   public boolean isEnablePartialInsert() {
     return enablePartialInsert;
   }
@@ -2330,88 +2143,6 @@ public class IoTDBConfig {
     this.rpcThriftCompressionEnable = rpcThriftCompressionEnable;
   }
 
-  public boolean isMetaDataCacheEnable() {
-    return metaDataCacheEnable;
-  }
-
-  public void setMetaDataCacheEnable(boolean metaDataCacheEnable) {
-    this.metaDataCacheEnable = metaDataCacheEnable;
-  }
-
-  public long getAllocateMemoryForBloomFilterCache() {
-    return allocateMemoryForBloomFilterCache;
-  }
-
-  public void setAllocateMemoryForBloomFilterCache(long allocateMemoryForBloomFilterCache) {
-    this.allocateMemoryForBloomFilterCache = allocateMemoryForBloomFilterCache;
-  }
-
-  public long getAllocateMemoryForTimeSeriesMetaDataCache() {
-    return allocateMemoryForTimeSeriesMetaDataCache;
-  }
-
-  public void setAllocateMemoryForTimeSeriesMetaDataCache(
-      long allocateMemoryForTimeSeriesMetaDataCache) {
-    this.allocateMemoryForTimeSeriesMetaDataCache = allocateMemoryForTimeSeriesMetaDataCache;
-  }
-
-  public long getAllocateMemoryForChunkCache() {
-    return allocateMemoryForChunkCache;
-  }
-
-  public void setAllocateMemoryForChunkCache(long allocateMemoryForChunkCache) {
-    this.allocateMemoryForChunkCache = allocateMemoryForChunkCache;
-  }
-
-  public long getAllocateMemoryForCoordinator() {
-    return allocateMemoryForCoordinator;
-  }
-
-  public void setAllocateMemoryForCoordinator(long allocateMemoryForCoordinator) {
-    this.allocateMemoryForCoordinator = allocateMemoryForCoordinator;
-  }
-
-  public long getAllocateMemoryForOperators() {
-    return allocateMemoryForOperators;
-  }
-
-  public void setAllocateMemoryForOperators(long allocateMemoryForOperators) {
-    this.allocateMemoryForOperators = allocateMemoryForOperators;
-  }
-
-  public long getAllocateMemoryForDataExchange() {
-    return allocateMemoryForDataExchange;
-  }
-
-  public void setAllocateMemoryForDataExchange(long allocateMemoryForDataExchange) {
-    this.allocateMemoryForDataExchange = allocateMemoryForDataExchange;
-    this.maxBytesPerFragmentInstance = allocateMemoryForDataExchange / queryThreadCount;
-  }
-
-  public long getAllocateMemoryForTimeIndex() {
-    return allocateMemoryForTimeIndex;
-  }
-
-  public void setAllocateMemoryForTimeIndex(long allocateMemoryForTimeIndex) {
-    this.allocateMemoryForTimeIndex = allocateMemoryForTimeIndex;
-  }
-
-  public long getAllocateMemoryForTimePartitionInfo() {
-    return allocateMemoryForTimePartitionInfo;
-  }
-
-  public void setAllocateMemoryForTimePartitionInfo(long allocateMemoryForTimePartitionInfo) {
-    this.allocateMemoryForTimePartitionInfo = allocateMemoryForTimePartitionInfo;
-  }
-
-  public boolean isEnableQueryMemoryEstimation() {
-    return enableQueryMemoryEstimation;
-  }
-
-  public void setEnableQueryMemoryEstimation(boolean enableQueryMemoryEstimation) {
-    this.enableQueryMemoryEstimation = enableQueryMemoryEstimation;
-  }
-
   public boolean isAutoCreateSchemaEnabled() {
     return enableAutoCreateSchema;
   }
@@ -2796,14 +2527,6 @@ public class IoTDBConfig {
     this.maxWaitingTimeWhenInsertBlockedInMs = maxWaitingTimeWhenInsertBlocked;
   }
 
-  public void setMaxOffHeapMemoryBytes(long maxOffHeapMemoryBytes) {
-    this.maxOffHeapMemoryBytes = maxOffHeapMemoryBytes;
-  }
-
-  public long getMaxOffHeapMemoryBytes() {
-    return maxOffHeapMemoryBytes;
-  }
-
   public long getSlowQueryThreshold() {
     return slowQueryThreshold;
   }
@@ -3463,38 +3186,6 @@ public class IoTDBConfig {
     return new TEndPoint(rpcAddress, rpcPort);
   }
 
-  public int[] getSchemaMemoryProportion() {
-    return schemaMemoryProportion;
-  }
-
-  public void setSchemaMemoryProportion(int[] schemaMemoryProportion) {
-    this.schemaMemoryProportion = schemaMemoryProportion;
-  }
-
-  public long getAllocateMemoryForSchemaRegion() {
-    return allocateMemoryForSchemaRegion;
-  }
-
-  public void setAllocateMemoryForSchemaRegion(long allocateMemoryForSchemaRegion) {
-    this.allocateMemoryForSchemaRegion = allocateMemoryForSchemaRegion;
-  }
-
-  public long getAllocateMemoryForSchemaCache() {
-    return allocateMemoryForSchemaCache;
-  }
-
-  public void setAllocateMemoryForSchemaCache(long allocateMemoryForSchemaCache) {
-    this.allocateMemoryForSchemaCache = allocateMemoryForSchemaCache;
-  }
-
-  public long getAllocateMemoryForPartitionCache() {
-    return allocateMemoryForPartitionCache;
-  }
-
-  public void setAllocateMemoryForPartitionCache(long allocateMemoryForPartitionCache) {
-    this.allocateMemoryForPartitionCache = allocateMemoryForPartitionCache;
-  }
-
   public String getDataNodeSchemaCacheEvictionPolicy() {
     return dataNodeSchemaCacheEvictionPolicy;
   }
@@ -3576,34 +3267,6 @@ public class IoTDBConfig {
     this.driverTaskExecutionTimeSliceInMs = driverTaskExecutionTimeSliceInMs;
   }
 
-  public double getWriteProportionForMemtable() {
-    return writeProportionForMemtable;
-  }
-
-  public void setWriteProportionForMemtable(double writeProportionForMemtable) {
-    this.writeProportionForMemtable = writeProportionForMemtable;
-  }
-
-  public double getCompactionProportion() {
-    return compactionProportion;
-  }
-
-  public double getWalBufferQueueProportion() {
-    return walBufferQueueProportion;
-  }
-
-  public void setWalBufferQueueProportion(double walBufferQueueProportion) {
-    this.walBufferQueueProportion = walBufferQueueProportion;
-  }
-
-  public double getDevicePathCacheProportion() {
-    return devicePathCacheProportion;
-  }
-
-  public void setDevicePathCacheProportion(double devicePathCacheProportion) {
-    this.devicePathCacheProportion = devicePathCacheProportion;
-  }
-
   public static String getEnvironmentVariables() {
     return "\n\t"
         + IoTDBConstant.IOTDB_HOME
@@ -3622,10 +3285,6 @@ public class IoTDBConfig {
         + ";";
   }
 
-  public void setCompactionProportion(double compactionProportion) {
-    this.compactionProportion = compactionProportion;
-  }
-
   public long getThrottleThreshold() {
     return throttleThreshold;
   }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index ca42b712106..cff92d4d359 100755
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.commons.conf.ConfigurationFileUtils;
 import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.commons.conf.TrimProperties;
 import org.apache.iotdb.commons.exception.BadNodeUrlException;
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.commons.schema.SchemaConstant;
 import org.apache.iotdb.commons.service.metric.MetricService;
 import org.apache.iotdb.commons.utils.NodeUrlUtils;
@@ -49,7 +50,6 @@ import org.apache.iotdb.db.storageengine.dataregion.wal.utils.WALMode;
 import org.apache.iotdb.db.storageengine.rescon.disk.TierManager;
 import org.apache.iotdb.db.storageengine.rescon.memory.SystemInfo;
 import org.apache.iotdb.db.utils.DateTimeUtils;
-import org.apache.iotdb.db.utils.MemUtils;
 import org.apache.iotdb.db.utils.datastructure.TVListSortAlgorithm;
 import org.apache.iotdb.external.api.IPropertiesLoader;
 import org.apache.iotdb.metrics.config.MetricConfigDescriptor;
@@ -96,6 +96,7 @@ public class IoTDBDescriptor {
   private static final CommonDescriptor commonDescriptor = CommonDescriptor.getInstance();
 
   private static final IoTDBConfig conf = new IoTDBConfig();
+  private static final DataNodeMemoryConfig memoryConfig = new DataNodeMemoryConfig();
 
   private static final long MAX_THROTTLE_THRESHOLD = 600 * 1024 * 1024 * 1024L;
 
@@ -159,6 +160,10 @@ public class IoTDBDescriptor {
     return conf;
   }
 
+  public DataNodeMemoryConfig getMemoryConfig() {
+    return memoryConfig;
+  }
+
   /**
    * get props url location
    *
@@ -282,55 +287,18 @@ public class IoTDBDescriptor {
             properties.getProperty(
                 IoTDBConstant.DN_RPC_PORT, Integer.toString(conf.getRpcPort()))));
 
-    conf.setBufferedArraysMemoryProportion(
-        Double.parseDouble(
-            properties.getProperty(
-                "buffered_arrays_memory_proportion",
-                Double.toString(conf.getBufferedArraysMemoryProportion()))));
-
     conf.setFlushProportion(
         Double.parseDouble(
             properties.getProperty(
                 "flush_proportion", Double.toString(conf.getFlushProportion()))));
 
-    final double rejectProportion =
-        Double.parseDouble(
-            properties.getProperty(
-                "reject_proportion", Double.toString(conf.getRejectProportion())));
-
-    final double walBufferQueueProportion =
-        Double.parseDouble(
-            properties.getProperty(
-                "wal_buffer_queue_proportion",
-                Double.toString(conf.getWalBufferQueueProportion())));
-
-    final double devicePathCacheProportion =
-        Double.parseDouble(
-            properties.getProperty(
-                "device_path_cache_proportion",
-                Double.toString(conf.getDevicePathCacheProportion())));
-
-    if (rejectProportion + walBufferQueueProportion + devicePathCacheProportion >= 1) {
-      LOGGER.warn(
-          "The sum of reject_proportion, wal_buffer_queue_proportion and device_path_cache_proportion is too large, use default values 0.8, 0.1 and 0.05.");
-    } else {
-      conf.setRejectProportion(rejectProportion);
-      conf.setWalBufferQueueProportion(walBufferQueueProportion);
-      conf.setDevicePathCacheProportion(devicePathCacheProportion);
-    }
-
     conf.setWriteMemoryVariationReportProportion(
         Double.parseDouble(
             properties.getProperty(
                 "write_memory_variation_report_proportion",
                 Double.toString(conf.getWriteMemoryVariationReportProportion()))));
 
-    conf.setMetaDataCacheEnable(
-        Boolean.parseBoolean(
-            properties.getProperty(
-                "meta_data_cache_enable", Boolean.toString(conf.isMetaDataCacheEnable()))));
-
-    initMemoryAllocate(properties);
+    memoryConfig.init(properties);
 
     String systemDir = properties.getProperty("dn_system_dir");
     if (systemDir == null) {
@@ -403,9 +371,6 @@ public class IoTDBDescriptor {
                 "max_waiting_time_when_insert_blocked",
                 Integer.toString(conf.getMaxWaitingTimeWhenInsertBlocked()))));
 
-    String offHeapMemoryStr = System.getProperty("OFF_HEAP_MEMORY");
-    conf.setMaxOffHeapMemoryBytes(MemUtils.strToBytesCnt(offHeapMemoryStr));
-
     conf.setIoTaskQueueSizeForFlushing(
         Integer.parseInt(
             properties.getProperty(
@@ -543,15 +508,6 @@ public class IoTDBDescriptor {
                 "default_index_window_range",
                 Integer.toString(conf.getDefaultIndexWindowRange()))));
 
-    conf.setQueryThreadCount(
-        Integer.parseInt(
-            properties.getProperty(
-                "query_thread_count", Integer.toString(conf.getQueryThreadCount()))));
-
-    if (conf.getQueryThreadCount() <= 0) {
-      conf.setQueryThreadCount(Runtime.getRuntime().availableProcessors());
-    }
-
     conf.setDegreeOfParallelism(
         Integer.parseInt(
             properties.getProperty(
@@ -1815,7 +1771,7 @@ public class IoTDBDescriptor {
             (int)
                 Math.min(
                     TSFileDescriptor.getInstance().getConfig().getMaxTsBlockSizeInBytes(),
-                    conf.getMaxBytesPerFragmentInstance()));
+                    memoryConfig.getMaxBytesPerFragmentInstance()));
 
     TSFileDescriptor.getInstance()
         .getConfig()
@@ -1993,7 +1949,7 @@ public class IoTDBDescriptor {
                       "select_into_insert_tablet_plan_row_limit"))));
 
       // update enable query memory estimation for memory control
-      conf.setEnableQueryMemoryEstimation(
+      memoryConfig.setEnableQueryMemoryEstimation(
           Boolean.parseBoolean(
               properties.getProperty(
                   "enable_query_memory_estimation",
@@ -2179,231 +2135,6 @@ public class IoTDBDescriptor {
     }
   }
 
-  private void initMemoryAllocate(TrimProperties properties) {
-    String memoryAllocateProportion = properties.getProperty("datanode_memory_proportion", null);
-    if (memoryAllocateProportion == null) {
-      memoryAllocateProportion =
-          properties.getProperty("storage_query_schema_consensus_free_memory_proportion");
-      if (memoryAllocateProportion != null) {
-        LOGGER.warn(
-            "The parameter storage_query_schema_consensus_free_memory_proportion is deprecated since v1.2.3, "
-                + "please use datanode_memory_proportion instead.");
-      }
-    }
-
-    if (memoryAllocateProportion != null) {
-      String[] proportions = memoryAllocateProportion.split(":");
-      int proportionSum = 0;
-      for (String proportion : proportions) {
-        proportionSum += Integer.parseInt(proportion.trim());
-      }
-      long maxMemoryAvailable = Runtime.getRuntime().maxMemory();
-      if (proportionSum != 0) {
-        conf.setAllocateMemoryForStorageEngine(
-            maxMemoryAvailable * Integer.parseInt(proportions[0].trim()) / proportionSum);
-        conf.setAllocateMemoryForRead(
-            maxMemoryAvailable * Integer.parseInt(proportions[1].trim()) / proportionSum);
-        conf.setAllocateMemoryForSchema(
-            maxMemoryAvailable * Integer.parseInt(proportions[2].trim()) / proportionSum);
-        conf.setAllocateMemoryForConsensus(
-            maxMemoryAvailable * Integer.parseInt(proportions[3].trim()) / proportionSum);
-        // if pipe proportion is set, use it, otherwise use the default value
-        if (proportions.length >= 6) {
-          conf.setAllocateMemoryForPipe(
-              maxMemoryAvailable * Integer.parseInt(proportions[4].trim()) / proportionSum);
-        } else {
-          conf.setAllocateMemoryForPipe(
-              (maxMemoryAvailable
-                      - (conf.getAllocateMemoryForStorageEngine()
-                          + conf.getAllocateMemoryForRead()
-                          + conf.getAllocateMemoryForSchema()
-                          + conf.getAllocateMemoryForConsensus()))
-                  / 2);
-        }
-      }
-    }
-
-    LOGGER.info("initial allocateMemoryForRead = {}", conf.getAllocateMemoryForRead());
-    LOGGER.info("initial allocateMemoryForWrite = {}", conf.getAllocateMemoryForStorageEngine());
-    LOGGER.info("initial allocateMemoryForSchema = {}", conf.getAllocateMemoryForSchema());
-    LOGGER.info("initial allocateMemoryForConsensus = {}", conf.getAllocateMemoryForConsensus());
-    LOGGER.info("initial allocateMemoryForPipe = {}", conf.getAllocateMemoryForPipe());
-
-    initSchemaMemoryAllocate(properties);
-    initStorageEngineAllocate(properties);
-
-    conf.setEnableQueryMemoryEstimation(
-        Boolean.parseBoolean(
-            properties.getProperty(
-                "enable_query_memory_estimation",
-                Boolean.toString(conf.isEnableQueryMemoryEstimation()))));
-
-    String queryMemoryAllocateProportion =
-        properties.getProperty("chunk_timeseriesmeta_free_memory_proportion");
-    if (queryMemoryAllocateProportion != null) {
-      String[] proportions = queryMemoryAllocateProportion.split(":");
-      int proportionSum = 0;
-      for (String proportion : proportions) {
-        proportionSum += Integer.parseInt(proportion.trim());
-      }
-      long maxMemoryAvailable = conf.getAllocateMemoryForRead();
-      if (proportionSum != 0) {
-        try {
-          conf.setAllocateMemoryForBloomFilterCache(
-              maxMemoryAvailable * Integer.parseInt(proportions[0].trim()) / proportionSum);
-          conf.setAllocateMemoryForChunkCache(
-              maxMemoryAvailable * Integer.parseInt(proportions[1].trim()) / proportionSum);
-          conf.setAllocateMemoryForTimeSeriesMetaDataCache(
-              maxMemoryAvailable * Integer.parseInt(proportions[2].trim()) / proportionSum);
-          conf.setAllocateMemoryForCoordinator(
-              maxMemoryAvailable * Integer.parseInt(proportions[3].trim()) / proportionSum);
-          conf.setAllocateMemoryForOperators(
-              maxMemoryAvailable * Integer.parseInt(proportions[4].trim()) / proportionSum);
-          conf.setAllocateMemoryForDataExchange(
-              maxMemoryAvailable * Integer.parseInt(proportions[5].trim()) / proportionSum);
-          conf.setAllocateMemoryForTimeIndex(
-              maxMemoryAvailable * Integer.parseInt(proportions[6].trim()) / proportionSum);
-        } catch (Exception e) {
-          throw new RuntimeException(
-              "Each subsection of configuration item chunkmeta_chunk_timeseriesmeta_free_memory_proportion"
-                  + " should be an integer, which is "
-                  + queryMemoryAllocateProportion,
-              e);
-        }
-      }
-    }
-
-    // metadata cache is disabled, we need to move all their allocated memory to other parts
-    if (!conf.isMetaDataCacheEnable()) {
-      long sum =
-          conf.getAllocateMemoryForBloomFilterCache()
-              + conf.getAllocateMemoryForChunkCache()
-              + conf.getAllocateMemoryForTimeSeriesMetaDataCache();
-      conf.setAllocateMemoryForBloomFilterCache(0);
-      conf.setAllocateMemoryForChunkCache(0);
-      conf.setAllocateMemoryForTimeSeriesMetaDataCache(0);
-      long partForDataExchange = sum / 2;
-      long partForOperators = sum - partForDataExchange;
-      conf.setAllocateMemoryForDataExchange(
-          conf.getAllocateMemoryForDataExchange() + partForDataExchange);
-      conf.setAllocateMemoryForOperators(conf.getAllocateMemoryForOperators() + partForOperators);
-    }
-  }
-
-  @SuppressWarnings("java:S3518")
-  private void initStorageEngineAllocate(TrimProperties properties) {
-    long storageMemoryTotal = conf.getAllocateMemoryForStorageEngine();
-    String valueOfStorageEngineMemoryProportion =
-        properties.getProperty("storage_engine_memory_proportion");
-    if (valueOfStorageEngineMemoryProportion != null) {
-      String[] storageProportionArray = valueOfStorageEngineMemoryProportion.split(":");
-      int storageEngineMemoryProportion = 0;
-      for (String proportion : storageProportionArray) {
-        int proportionValue = Integer.parseInt(proportion.trim());
-        if (proportionValue <= 0) {
-          LOGGER.warn(
-              "The value of storage_engine_memory_proportion is illegal, use default value 8:2 .");
-          return;
-        }
-        storageEngineMemoryProportion += proportionValue;
-      }
-      conf.setCompactionProportion(
-          (double) Integer.parseInt(storageProportionArray[1].trim())
-              / (double) storageEngineMemoryProportion);
-
-      String valueOfWriteMemoryProportion = properties.getProperty("write_memory_proportion");
-      if (valueOfWriteMemoryProportion != null) {
-        String[] writeProportionArray = valueOfWriteMemoryProportion.split(":");
-        int writeMemoryProportion = 0;
-        for (String proportion : writeProportionArray) {
-          int proportionValue = Integer.parseInt(proportion.trim());
-          writeMemoryProportion += proportionValue;
-          if (proportionValue <= 0) {
-            LOGGER.warn(
-                "The value of write_memory_proportion is illegal, use default value 19:1 .");
-            return;
-          }
-        }
-
-        double writeAllProportionOfStorageEngineMemory =
-            (double) Integer.parseInt(storageProportionArray[0].trim())
-                / storageEngineMemoryProportion;
-        double memTableProportion =
-            (double) Integer.parseInt(writeProportionArray[0].trim()) / writeMemoryProportion;
-        double timePartitionInfoProportion =
-            (double) Integer.parseInt(writeProportionArray[1].trim()) / writeMemoryProportion;
-        // writeProportionForMemtable = 8/10 * 19/20 = 0.76 default
-        conf.setWriteProportionForMemtable(
-            writeAllProportionOfStorageEngineMemory * memTableProportion);
-
-        // allocateMemoryForTimePartitionInfo = storageMemoryTotal * 8/10 * 1/20 default
-        conf.setAllocateMemoryForTimePartitionInfo(
-            (long)
-                ((writeAllProportionOfStorageEngineMemory * timePartitionInfoProportion)
-                    * storageMemoryTotal));
-      }
-    }
-  }
-
-  @SuppressWarnings("squid:S3518")
-  private void initSchemaMemoryAllocate(TrimProperties properties) {
-    long schemaMemoryTotal = conf.getAllocateMemoryForSchema();
-
-    String schemaMemoryPortionInput = properties.getProperty("schema_memory_proportion");
-    if (schemaMemoryPortionInput != null) {
-      String[] proportions = schemaMemoryPortionInput.split(":");
-      int loadedProportionSum = 0;
-      for (String proportion : proportions) {
-        loadedProportionSum += Integer.parseInt(proportion.trim());
-      }
-
-      if (loadedProportionSum != 0) {
-        conf.setSchemaMemoryProportion(
-            new int[] {
-              Integer.parseInt(proportions[0].trim()),
-              Integer.parseInt(proportions[1].trim()),
-              Integer.parseInt(proportions[2].trim())
-            });
-      }
-
-    } else {
-      schemaMemoryPortionInput = properties.getProperty("schema_memory_allocate_proportion");
-      if (schemaMemoryPortionInput != null) {
-        String[] proportions = schemaMemoryPortionInput.split(":");
-        int loadedProportionSum = 0;
-        for (String proportion : proportions) {
-          loadedProportionSum += Integer.parseInt(proportion.trim());
-        }
-
-        if (loadedProportionSum != 0) {
-          conf.setSchemaMemoryProportion(
-              new int[] {
-                Integer.parseInt(proportions[0].trim()),
-                Integer.parseInt(proportions[1].trim()) + Integer.parseInt(proportions[3].trim()),
-                Integer.parseInt(proportions[2].trim())
-              });
-        }
-      }
-    }
-
-    int proportionSum = 0;
-    for (int proportion : conf.getSchemaMemoryProportion()) {
-      proportionSum += proportion;
-    }
-
-    conf.setAllocateMemoryForSchemaRegion(
-        schemaMemoryTotal * conf.getSchemaMemoryProportion()[0] / proportionSum);
-    LOGGER.info("allocateMemoryForSchemaRegion = {}", conf.getAllocateMemoryForSchemaRegion());
-
-    conf.setAllocateMemoryForSchemaCache(
-        schemaMemoryTotal * conf.getSchemaMemoryProportion()[1] / proportionSum);
-    LOGGER.info("allocateMemoryForSchemaCache = {}", conf.getAllocateMemoryForSchemaCache());
-
-    conf.setAllocateMemoryForPartitionCache(
-        schemaMemoryTotal * conf.getSchemaMemoryProportion()[2] / proportionSum);
-    LOGGER.info("allocateMemoryForPartitionCache = {}", conf.getAllocateMemoryForPartitionCache());
-  }
-
   private void loadLoadTsFileProps(TrimProperties properties) {
     conf.setMaxAllocateMemoryRatioForLoad(
         Double.parseDouble(
@@ -2560,7 +2291,7 @@ public class IoTDBDescriptor {
           (float)
               Math.min(
                   Float.parseFloat(memoryBudgetInMb.trim()),
-                  0.2 * conf.getAllocateMemoryForRead()));
+                  0.2 * memoryConfig.getQueryEngineMemoryManager().getTotalMemorySizeInBytes()));
     }
 
     String readerTransformerCollectorMemoryProportion =
@@ -2865,9 +2596,15 @@ public class IoTDBDescriptor {
   }
 
   public void reclaimConsensusMemory() {
-    conf.setAllocateMemoryForStorageEngine(
-        conf.getAllocateMemoryForStorageEngine() + conf.getAllocateMemoryForConsensus());
-    SystemInfo.getInstance().allocateWriteMemory();
+    // first we need to release the memory allocated for consensus
+    MemoryManager storageEngineMemoryManager = memoryConfig.getStorageEngineMemoryManager();
+    MemoryManager consensusMemoryManager = memoryConfig.getConsensusMemoryManager();
+    long newSize =
+        storageEngineMemoryManager.getTotalMemorySizeInBytes()
+            + consensusMemoryManager.getTotalMemorySizeInBytes();
+    consensusMemoryManager.setTotalMemorySizeInBytes(0);
+    storageEngineMemoryManager.setTotalMemorySizeInBytesWithReload(newSize);
+    SystemInfo.getInstance().loadWriteMemory();
   }
 
   private static class IoTDBDescriptorHolder {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java
index 42d0830e711..38ce6a0f158 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java
@@ -23,6 +23,8 @@ import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
 import org.apache.iotdb.common.rpc.thrift.TEndPoint;
 import org.apache.iotdb.commons.consensus.ConsensusGroupId;
 import org.apache.iotdb.commons.consensus.DataRegionId;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.pipe.agent.plugin.builtin.BuiltinPipePlugin;
 import org.apache.iotdb.consensus.ConsensusFactory;
 import org.apache.iotdb.consensus.IConsensus;
@@ -33,6 +35,7 @@ import org.apache.iotdb.consensus.config.PipeConsensusConfig;
 import org.apache.iotdb.consensus.config.PipeConsensusConfig.ReplicateMode;
 import org.apache.iotdb.consensus.config.RatisConfig;
 import org.apache.iotdb.consensus.config.RatisConfig.Snapshot;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.consensus.statemachine.dataregion.DataRegionStateMachine;
@@ -76,6 +79,8 @@ public class DataRegionConsensusImpl {
   private static class DataRegionConsensusImplHolder {
 
     private static final IoTDBConfig CONF = IoTDBDescriptor.getInstance().getConfig();
+    private static final DataNodeMemoryConfig MEMORY_CONFIG =
+        IoTDBDescriptor.getInstance().getMemoryConfig();
 
     private static IConsensus INSTANCE;
 
@@ -110,6 +115,10 @@ public class DataRegionConsensusImpl {
     }
 
     private static ConsensusConfig buildConsensusConfig() {
+      IMemoryBlock memoryBlock =
+          MEMORY_CONFIG
+              .getConsensusMemoryManager()
+              .exactAllocate("Consensus", MemoryBlockType.DYNAMIC);
       return ConsensusConfig.newBuilder()
           .setThisNodeId(CONF.getDataNodeId())
           .setThisNode(new TEndPoint(CONF.getInternalAddress(), CONF.getDataRegionConsensusPort()))
@@ -133,7 +142,7 @@ public class DataRegionConsensusImpl {
                   .setReplication(
                       IoTConsensusConfig.Replication.newBuilder()
                           .setWalThrottleThreshold(CONF.getThrottleThreshold())
-                          .setAllocateMemoryForConsensus(CONF.getAllocateMemoryForConsensus())
+                          .setConsensusMemoryBlock(memoryBlock)
                           .setMaxLogEntriesNumPerBatch(CONF.getMaxLogEntriesNumPerBatch())
                           .setMaxSizePerBatch(CONF.getMaxSizePerBatch())
                           .setMaxPendingBatchesNum(CONF.getMaxPendingBatchesNum())
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryBlock.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryBlock.java
index 07f5b904523..5f4fcf0dd77 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryBlock.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryBlock.java
@@ -161,7 +161,7 @@ public class PipeMemoryBlock implements AutoCloseable {
   @Override
   public String toString() {
     return "PipeMemoryBlock{"
-        + "memoryUsageInBytes="
+        + "usedMemoryInBytes="
         + memoryUsageInBytes.get()
         + ", isReleased="
         + isReleased
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryManager.java
index 6a2f63858f6..062505b7229 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryManager.java
@@ -20,6 +20,8 @@
 package org.apache.iotdb.db.pipe.resource.memory;
 
 import org.apache.iotdb.commons.exception.pipe.PipeRuntimeOutOfMemoryCriticalException;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.pipe.config.PipeConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.pipe.agent.PipeDataNodeAgent;
@@ -46,12 +48,15 @@ public class PipeMemoryManager {
   private static final long MEMORY_ALLOCATE_RETRY_INTERVAL_IN_MS =
       PipeConfig.getInstance().getPipeMemoryAllocateRetryIntervalInMs();
 
-  private static final long TOTAL_MEMORY_SIZE_IN_BYTES =
-      IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForPipe();
   private static final long MEMORY_ALLOCATE_MIN_SIZE_IN_BYTES =
       PipeConfig.getInstance().getPipeMemoryAllocateMinSizeInBytes();
 
-  private long usedMemorySizeInBytes;
+  // TODO @spricoder: consider combine memory block and used MemorySizeInBytes
+  private IMemoryBlock memoryBlock =
+      IoTDBDescriptor.getInstance()
+          .getMemoryConfig()
+          .getPipeMemoryManager()
+          .exactAllocate("Stream", MemoryBlockType.DYNAMIC);
 
   private static final double EXCEED_PROTECT_THRESHOLD = 0.95;
 
@@ -87,19 +92,19 @@ public class PipeMemoryManager {
   // 3. The sum of the memory proportion occupied by the tablet memory block and the tsfile memory
   // block does not exceed TABLET_MEMORY_REJECT_THRESHOLD + TS_FILE_MEMORY_REJECT_THRESHOLD
 
-  private static double allowedMaxMemorySizeInBytesOfTabletsAndTsFiles() {
+  private double allowedMaxMemorySizeInBytesOfTabletsAndTsFiles() {
     return (TABLET_MEMORY_REJECT_THRESHOLD + TS_FILE_MEMORY_REJECT_THRESHOLD)
-        * TOTAL_MEMORY_SIZE_IN_BYTES;
+        * memoryBlock.getTotalMemorySizeInBytes();
   }
 
-  private static double allowedMaxMemorySizeInBytesOfTablets() {
+  private double allowedMaxMemorySizeInBytesOfTablets() {
     return (TABLET_MEMORY_REJECT_THRESHOLD + TS_FILE_MEMORY_REJECT_THRESHOLD / 2)
-        * TOTAL_MEMORY_SIZE_IN_BYTES;
+        * memoryBlock.getTotalMemorySizeInBytes();
   }
 
-  private static double allowedMaxMemorySizeInBytesOfTsTiles() {
+  private double allowedMaxMemorySizeInBytesOfTsTiles() {
     return (TS_FILE_MEMORY_REJECT_THRESHOLD + TABLET_MEMORY_REJECT_THRESHOLD / 2)
-        * TOTAL_MEMORY_SIZE_IN_BYTES;
+        * memoryBlock.getTotalMemorySizeInBytes();
   }
 
   public boolean isEnough4TabletParsing() {
@@ -171,7 +176,9 @@ public class PipeMemoryManager {
           String.format(
               "forceAllocateForTablet: failed to allocate because there's too much memory for tablets, "
                   + "total memory size %d bytes, used memory for tablet size %d bytes, requested memory size %d bytes",
-              TOTAL_MEMORY_SIZE_IN_BYTES, usedMemorySizeInBytesOfTablets, tabletSizeInBytes));
+              memoryBlock.getTotalMemorySizeInBytes(),
+              usedMemorySizeInBytesOfTablets,
+              tabletSizeInBytes));
     }
 
     synchronized (this) {
@@ -211,7 +218,9 @@ public class PipeMemoryManager {
           String.format(
               "forceAllocateForTsFile: failed to allocate because there's too much memory for tsfiles, "
                   + "total memory size %d bytes, used memory for tsfile size %d bytes, requested memory size %d bytes",
-              TOTAL_MEMORY_SIZE_IN_BYTES, usedMemorySizeInBytesOfTsFiles, tsFileSizeInBytes));
+              memoryBlock.getTotalMemorySizeInBytes(),
+              usedMemorySizeInBytesOfTsFiles,
+              tsFileSizeInBytes));
     }
 
     synchronized (this) {
@@ -237,7 +246,8 @@ public class PipeMemoryManager {
     }
 
     for (int i = 1; i <= MEMORY_ALLOCATE_MAX_RETRIES; i++) {
-      if (TOTAL_MEMORY_SIZE_IN_BYTES - usedMemorySizeInBytes >= sizeInBytes) {
+      if (memoryBlock.getTotalMemorySizeInBytes() - memoryBlock.getUsedMemoryInBytes()
+          >= sizeInBytes) {
         return registerMemoryBlock(sizeInBytes, type);
       }
 
@@ -256,8 +266,8 @@ public class PipeMemoryManager {
                 + "total memory size %d bytes, used memory size %d bytes, "
                 + "requested memory size %d bytes",
             MEMORY_ALLOCATE_MAX_RETRIES,
-            TOTAL_MEMORY_SIZE_IN_BYTES,
-            usedMemorySizeInBytes,
+            memoryBlock.getTotalMemorySizeInBytes(),
+            memoryBlock.getUsedMemoryInBytes(),
             sizeInBytes));
   }
 
@@ -281,7 +291,7 @@ public class PipeMemoryManager {
     }
 
     if (oldSize >= targetSize) {
-      usedMemorySizeInBytes -= oldSize - targetSize;
+      memoryBlock.release(oldSize - targetSize);
       if (block instanceof PipeTabletMemoryBlock) {
         usedMemorySizeInBytesOfTablets -= oldSize - targetSize;
       }
@@ -299,8 +309,9 @@ public class PipeMemoryManager {
 
     long sizeInBytes = targetSize - oldSize;
     for (int i = 1; i <= MEMORY_ALLOCATE_MAX_RETRIES; i++) {
-      if (TOTAL_MEMORY_SIZE_IN_BYTES - usedMemorySizeInBytes >= sizeInBytes) {
-        usedMemorySizeInBytes += sizeInBytes;
+      if (memoryBlock.getTotalMemorySizeInBytes() - memoryBlock.getUsedMemoryInBytes()
+          >= sizeInBytes) {
+        memoryBlock.forceAllocateWithoutLimitation(sizeInBytes);
         if (block instanceof PipeTabletMemoryBlock) {
           usedMemorySizeInBytesOfTablets += sizeInBytes;
         }
@@ -326,8 +337,8 @@ public class PipeMemoryManager {
                 + "total memory size %d bytes, used memory size %d bytes, "
                 + "requested memory size %d bytes",
             MEMORY_ALLOCATE_MAX_RETRIES,
-            TOTAL_MEMORY_SIZE_IN_BYTES,
-            usedMemorySizeInBytes,
+            memoryBlock.getTotalMemorySizeInBytes(),
+            memoryBlock.getUsedMemoryInBytes(),
             sizeInBytes));
   }
 
@@ -354,13 +365,15 @@ public class PipeMemoryManager {
       return registerMemoryBlock(0);
     }
 
-    if (TOTAL_MEMORY_SIZE_IN_BYTES - usedMemorySizeInBytes >= sizeInBytes
-        && (float) usedMemorySizeInBytes / TOTAL_MEMORY_SIZE_IN_BYTES < usedThreshold) {
+    if (memoryBlock.getTotalMemorySizeInBytes() - memoryBlock.getUsedMemoryInBytes() >= sizeInBytes
+        && (float) memoryBlock.getUsedMemoryInBytes() / memoryBlock.getTotalMemorySizeInBytes()
+            < usedThreshold) {
       return forceAllocate(sizeInBytes);
     } else {
       long memoryToShrink =
           Math.max(
-              usedMemorySizeInBytes - (long) (TOTAL_MEMORY_SIZE_IN_BYTES * usedThreshold),
+              memoryBlock.getUsedMemoryInBytes()
+                  - (long) (memoryBlock.getTotalMemorySizeInBytes() * usedThreshold),
               sizeInBytes);
       if (tryShrink4Allocate(memoryToShrink)) {
         return forceAllocate(sizeInBytes);
@@ -379,20 +392,23 @@ public class PipeMemoryManager {
       return new PipeMemoryBlock(sizeInBytes);
     }
 
-    if (sizeInBytes == 0 || TOTAL_MEMORY_SIZE_IN_BYTES - usedMemorySizeInBytes >= sizeInBytes) {
+    if (sizeInBytes == 0
+        || memoryBlock.getTotalMemorySizeInBytes() - memoryBlock.getUsedMemoryInBytes()
+            >= sizeInBytes) {
       return registerMemoryBlock(sizeInBytes);
     }
 
     long sizeToAllocateInBytes = sizeInBytes;
     while (sizeToAllocateInBytes > MEMORY_ALLOCATE_MIN_SIZE_IN_BYTES) {
-      if (TOTAL_MEMORY_SIZE_IN_BYTES - usedMemorySizeInBytes >= sizeToAllocateInBytes) {
+      if (memoryBlock.getTotalMemorySizeInBytes() - memoryBlock.getUsedMemoryInBytes()
+          >= sizeToAllocateInBytes) {
         LOGGER.info(
             "tryAllocate: allocated memory, "
                 + "total memory size {} bytes, used memory size {} bytes, "
                 + "original requested memory size {} bytes, "
                 + "actual requested memory size {} bytes",
-            TOTAL_MEMORY_SIZE_IN_BYTES,
-            usedMemorySizeInBytes,
+            memoryBlock.getTotalMemorySizeInBytes(),
+            memoryBlock.getUsedMemoryInBytes(),
             sizeInBytes,
             sizeToAllocateInBytes);
         return registerMemoryBlock(sizeToAllocateInBytes);
@@ -410,8 +426,8 @@ public class PipeMemoryManager {
               + "total memory size {} bytes, used memory size {} bytes, "
               + "original requested memory size {} bytes, "
               + "actual requested memory size {} bytes",
-          TOTAL_MEMORY_SIZE_IN_BYTES,
-          usedMemorySizeInBytes,
+          memoryBlock.getTotalMemorySizeInBytes(),
+          memoryBlock.getUsedMemoryInBytes(),
           sizeInBytes,
           sizeToAllocateInBytes);
       return registerMemoryBlock(sizeToAllocateInBytes);
@@ -420,8 +436,8 @@ public class PipeMemoryManager {
           "tryAllocate: failed to allocate memory, "
               + "total memory size {} bytes, used memory size {} bytes, "
               + "requested memory size {} bytes",
-          TOTAL_MEMORY_SIZE_IN_BYTES,
-          usedMemorySizeInBytes,
+          memoryBlock.getTotalMemorySizeInBytes(),
+          memoryBlock.getUsedMemoryInBytes(),
           sizeInBytes);
       return registerMemoryBlock(0);
     }
@@ -433,8 +449,9 @@ public class PipeMemoryManager {
       return false;
     }
 
-    if (TOTAL_MEMORY_SIZE_IN_BYTES - usedMemorySizeInBytes >= memoryInBytesNeededToBeAllocated) {
-      usedMemorySizeInBytes += memoryInBytesNeededToBeAllocated;
+    if (memoryBlock.getTotalMemorySizeInBytes() - memoryBlock.getUsedMemoryInBytes()
+        >= memoryInBytesNeededToBeAllocated) {
+      memoryBlock.forceAllocateWithoutLimitation(memoryInBytesNeededToBeAllocated);
       if (block instanceof PipeTabletMemoryBlock) {
         usedMemorySizeInBytesOfTablets += memoryInBytesNeededToBeAllocated;
       }
@@ -470,7 +487,7 @@ public class PipeMemoryManager {
     // It's good for performance and will not trigger concurrent issues.
     // If forceResize is called on it, we will add it to the allocated blocks.
     if (sizeInBytes > 0) {
-      usedMemorySizeInBytes += sizeInBytes;
+      memoryBlock.forceAllocateWithoutLimitation(sizeInBytes);
       allocatedBlocks.add(returnedMemoryBlock);
     }
 
@@ -486,7 +503,8 @@ public class PipeMemoryManager {
       for (final PipeMemoryBlock block : shuffledBlocks) {
         if (block.shrink()) {
           hasAtLeastOneBlockShrinkable = true;
-          if (TOTAL_MEMORY_SIZE_IN_BYTES - usedMemorySizeInBytes >= sizeInBytes) {
+          if (memoryBlock.getTotalMemorySizeInBytes() - memoryBlock.getUsedMemoryInBytes()
+              >= sizeInBytes) {
             return true;
           }
         }
@@ -502,11 +520,11 @@ public class PipeMemoryManager {
 
     long blockSum =
         allocatedBlocks.stream().mapToLong(PipeMemoryBlock::getMemoryUsageInBytes).sum();
-    if (blockSum != usedMemorySizeInBytes) {
+    if (blockSum != memoryBlock.getUsedMemoryInBytes()) {
       LOGGER.warn(
           "tryExpandAllAndCheckConsistency: memory usage is not consistent with allocated blocks,"
               + " usedMemorySizeInBytes is {} but sum of all blocks is {}",
-          usedMemorySizeInBytes,
+          memoryBlock.getUsedMemoryInBytes(),
           blockSum);
     }
 
@@ -543,7 +561,7 @@ public class PipeMemoryManager {
     }
 
     allocatedBlocks.remove(block);
-    usedMemorySizeInBytes -= block.getMemoryUsageInBytes();
+    memoryBlock.release(block.getMemoryUsageInBytes());
     if (block instanceof PipeTabletMemoryBlock) {
       usedMemorySizeInBytesOfTablets -= block.getMemoryUsageInBytes();
     }
@@ -560,7 +578,7 @@ public class PipeMemoryManager {
       return false;
     }
 
-    usedMemorySizeInBytes -= sizeInBytes;
+    memoryBlock.release(sizeInBytes);
     if (block instanceof PipeTabletMemoryBlock) {
       usedMemorySizeInBytesOfTablets -= sizeInBytes;
     }
@@ -575,7 +593,7 @@ public class PipeMemoryManager {
   }
 
   public long getUsedMemorySizeInBytes() {
-    return usedMemorySizeInBytes;
+    return memoryBlock.getUsedMemoryInBytes();
   }
 
   public long getUsedMemorySizeInBytesOfTablets() {
@@ -587,10 +605,10 @@ public class PipeMemoryManager {
   }
 
   public long getFreeMemorySizeInBytes() {
-    return TOTAL_MEMORY_SIZE_IN_BYTES - usedMemorySizeInBytes;
+    return memoryBlock.getFreeMemoryInBytes();
   }
 
   public long getTotalMemorySizeInBytes() {
-    return TOTAL_MEMORY_SIZE_IN_BYTES;
+    return memoryBlock.getTotalMemorySizeInBytes();
   }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/SharedTsBlockQueue.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/SharedTsBlockQueue.java
index f3810426398..e28ddb47bf7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/SharedTsBlockQueue.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/SharedTsBlockQueue.java
@@ -80,7 +80,7 @@ public class SharedTsBlockQueue {
   private LocalSinkChannel sinkChannel;
 
   private long maxBytesCanReserve =
-      IoTDBDescriptor.getInstance().getConfig().getMaxBytesPerFragmentInstance();
+      IoTDBDescriptor.getInstance().getMemoryConfig().getMaxBytesPerFragmentInstance();
 
   // used for SharedTsBlockQueue listener
   private final ExecutorService executorService;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/sink/ShuffleSinkHandle.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/sink/ShuffleSinkHandle.java
index 90b135dcc60..c0bacd2292e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/sink/ShuffleSinkHandle.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/sink/ShuffleSinkHandle.java
@@ -68,7 +68,7 @@ public class ShuffleSinkHandle implements ISinkHandle {
 
   /** max bytes this ShuffleSinkHandle can reserve. */
   private long maxBytesCanReserve =
-      IoTDBDescriptor.getInstance().getConfig().getMaxBytesPerFragmentInstance();
+      IoTDBDescriptor.getInstance().getMemoryConfig().getMaxBytesPerFragmentInstance();
 
   private static final long INSTANCE_SIZE =
       RamUsageEstimator.shallowSizeOfInstance(ShuffleSinkHandle.class)
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/sink/SinkChannel.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/sink/SinkChannel.java
index 8915938eb03..d47dd6ca2bf 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/sink/SinkChannel.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/sink/SinkChannel.java
@@ -117,7 +117,7 @@ public class SinkChannel implements ISinkChannel {
 
   /** max bytes this SinkChannel can reserve. */
   private long maxBytesCanReserve =
-      IoTDBDescriptor.getInstance().getConfig().getMaxBytesPerFragmentInstance();
+      IoTDBDescriptor.getInstance().getMemoryConfig().getMaxBytesPerFragmentInstance();
 
   private static final DataExchangeCostMetricSet DATA_EXCHANGE_COST_METRIC_SET =
       DataExchangeCostMetricSet.getInstance();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/source/SourceHandle.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/source/SourceHandle.java
index 27e8c578b05..f6f5a919451 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/source/SourceHandle.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/source/SourceHandle.java
@@ -108,7 +108,7 @@ public class SourceHandle implements ISourceHandle {
 
   /** max bytes this SourceHandle can reserve. */
   private long maxBytesCanReserve =
-      IoTDBDescriptor.getInstance().getConfig().getMaxBytesPerFragmentInstance();
+      IoTDBDescriptor.getInstance().getMemoryConfig().getMaxBytesPerFragmentInstance();
 
   /**
    * this is set to true after calling isBlocked() at least once which indicates that this
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/LocalMemoryManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/LocalMemoryManager.java
index bbd33eb28ca..03766ab5276 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/LocalMemoryManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/LocalMemoryManager.java
@@ -30,11 +30,12 @@ public class LocalMemoryManager {
   private final MemoryPool queryPool;
 
   public LocalMemoryManager() {
+    // TODO @spricoder: why this pool is only used for query data exchange
     queryPool =
         new MemoryPool(
             "read",
-            IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForDataExchange(),
-            IoTDBDescriptor.getInstance().getConfig().getMaxBytesPerFragmentInstance());
+            IoTDBDescriptor.getInstance().getMemoryConfig().getDataExchangeMemoryManager(),
+            IoTDBDescriptor.getInstance().getMemoryConfig().getMaxBytesPerFragmentInstance());
   }
 
   public MemoryPool getQueryPool() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/MemoryPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/MemoryPool.java
index 638fb694c04..f8c8f2d301c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/MemoryPool.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/MemoryPool.java
@@ -19,6 +19,9 @@
 
 package org.apache.iotdb.db.queryengine.execution.memory;
 
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.commons.utils.TestOnly;
 import org.apache.iotdb.db.exception.runtime.MemoryLeakException;
 
@@ -38,7 +41,6 @@ import java.util.Map;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Collectors;
 
 /** A thread-safe memory pool. */
@@ -112,11 +114,9 @@ public class MemoryPool {
   }
 
   private final String id;
-  private final long maxBytes;
+  private final IMemoryBlock memoryBlock;
   private final long maxBytesPerFragmentInstance;
 
-  private final AtomicLong remainingBytes;
-
   /** queryId -> fragmentInstanceId -> planNodeId -> bytesReserved. */
   private final Map<String, Map<String, Map<String, Long>>> queryMemoryReservations =
       new ConcurrentHashMap<>();
@@ -124,17 +124,21 @@ public class MemoryPool {
   private final Queue<MemoryReservationFuture<Void>> memoryReservationFutures =
       new ConcurrentLinkedQueue<>();
 
-  public MemoryPool(String id, long maxBytes, long maxBytesPerFragmentInstance) {
+  public MemoryPool(String id, MemoryManager memoryManager, long maxBytesPerFragmentInstance) {
     this.id = Validate.notNull(id, "id can not be null.");
-    Validate.isTrue(maxBytes > 0L, "max bytes should be greater than zero: %d", maxBytes);
-    this.maxBytes = maxBytes;
+    this.memoryBlock =
+        memoryManager.exactAllocate(memoryManager.getName(), MemoryBlockType.DYNAMIC);
+    Validate.isTrue(
+        this.memoryBlock.getTotalMemorySizeInBytes() > 0L,
+        "max bytes should be greater than zero: %d",
+        this.memoryBlock.getTotalMemorySizeInBytes());
     Validate.isTrue(
-        maxBytesPerFragmentInstance > 0L && maxBytesPerFragmentInstance <= maxBytes,
+        maxBytesPerFragmentInstance > 0L
+            && maxBytesPerFragmentInstance <= this.memoryBlock.getTotalMemorySizeInBytes(),
         "max bytes per FI should be in (0,maxBytes]. maxBytesPerFI: %d, maxBytes: %d",
         maxBytesPerFragmentInstance,
-        maxBytes);
+        this.memoryBlock.getTotalMemorySizeInBytes());
     this.maxBytesPerFragmentInstance = maxBytesPerFragmentInstance;
-    this.remainingBytes = new AtomicLong(maxBytes);
   }
 
   public String getId() {
@@ -142,11 +146,11 @@ public class MemoryPool {
   }
 
   public long getMaxBytes() {
-    return maxBytes;
+    return memoryBlock.getTotalMemorySizeInBytes();
   }
 
   public long getRemainingBytes() {
-    return remainingBytes.get();
+    return memoryBlock.getFreeMemoryInBytes();
   }
 
   public int getQueryMemoryReservationSize() {
@@ -337,7 +341,7 @@ public class MemoryPool {
       throw new IllegalArgumentException("RelatedMemoryReserved can't be null when freeing memory");
     }
 
-    remainingBytes.addAndGet(bytes);
+    memoryBlock.release(bytes);
 
     if (memoryReservationFutures.isEmpty()) {
       return;
@@ -378,7 +382,7 @@ public class MemoryPool {
   }
 
   public long getReservedBytes() {
-    return maxBytes - remainingBytes.get();
+    return memoryBlock.getUsedMemoryInBytes();
   }
 
   public boolean tryReserve(
@@ -387,14 +391,14 @@ public class MemoryPool {
       String planNodeId,
       long bytesToReserve,
       long maxBytesCanReserve) {
-    long tryRemainingBytes = remainingBytes.addAndGet(-bytesToReserve);
+    long tryUsedBytes = memoryBlock.forceAllocateWithoutLimitation(bytesToReserve);
     long queryRemainingBytes =
         maxBytesCanReserve
             - queryMemoryReservations
                 .get(queryId)
                 .get(fragmentInstanceId)
                 .merge(planNodeId, bytesToReserve, Long::sum);
-    return tryRemainingBytes >= 0 && queryRemainingBytes >= 0;
+    return tryUsedBytes <= memoryBlock.getTotalMemorySizeInBytes() && queryRemainingBytes >= 0;
   }
 
   private void rollbackReserve(
@@ -403,6 +407,6 @@ public class MemoryPool {
         .get(queryId)
         .get(fragmentInstanceId)
         .merge(planNodeId, -bytesToReserve, Long::sum);
-    remainingBytes.addAndGet(bytesToReserve);
+    memoryBlock.release(bytesToReserve);
   }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/schedule/DriverScheduler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/schedule/DriverScheduler.java
index 80dec27b4cf..94a511a3b13 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/schedule/DriverScheduler.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/schedule/DriverScheduler.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.commons.exception.StartupException;
 import org.apache.iotdb.commons.service.IService;
 import org.apache.iotdb.commons.service.ServiceType;
 import org.apache.iotdb.commons.utils.TestOnly;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.queryengine.common.FragmentInstanceId;
@@ -70,7 +71,8 @@ public class DriverScheduler implements IDriverScheduler, IService {
 
   private static final Logger logger = LoggerFactory.getLogger(DriverScheduler.class);
   private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private static final double LEVEL_TIME_MULTIPLIER = 2;
 
   public static DriverScheduler getInstance() {
@@ -87,7 +89,7 @@ public class DriverScheduler implements IDriverScheduler, IService {
   private IMPPDataExchangeManager blockManager;
 
   private static final int QUERY_MAX_CAPACITY = config.getMaxAllowedConcurrentQueries();
-  private static final int WORKER_THREAD_NUM = config.getQueryThreadCount();
+  private static final int WORKER_THREAD_NUM = memoryConfig.getQueryThreadCount();
   private static final int TASK_MAX_CAPACITY = QUERY_MAX_CAPACITY * config.getDegreeOfParallelism();
   private static final long QUERY_TIMEOUT_MS = config.getQueryTimeoutThreshold();
   private final ThreadGroup workerGroups;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
index bf9ce458b5c..d04e616a90a 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
@@ -30,6 +30,8 @@ import org.apache.iotdb.commons.client.exception.ClientManagerException;
 import org.apache.iotdb.commons.consensus.ConfigRegionId;
 import org.apache.iotdb.commons.exception.IoTDBException;
 import org.apache.iotdb.commons.exception.MetadataException;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.partition.DataPartition;
 import org.apache.iotdb.commons.partition.DataPartitionQueryParam;
 import org.apache.iotdb.commons.partition.DataPartitionTable;
@@ -46,6 +48,7 @@ import org.apache.iotdb.confignode.rpc.thrift.TDatabaseSchemaResp;
 import org.apache.iotdb.confignode.rpc.thrift.TGetDatabaseReq;
 import org.apache.iotdb.confignode.rpc.thrift.TRegionRouteMapResp;
 import org.apache.iotdb.db.auth.AuthorityChecker;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.exception.sql.StatementAnalyzeException;
@@ -79,6 +82,8 @@ public class PartitionCache {
 
   private static final Logger logger = LoggerFactory.getLogger(PartitionCache.class);
   private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private static final List<String> ROOT_PATH = Arrays.asList("root", "**");
 
   /** calculate slotId by device */
@@ -113,8 +118,15 @@ public class PartitionCache {
       ConfigNodeClientManager.getInstance();
 
   private final CacheMetrics cacheMetrics;
+  private final IMemoryBlock memoryBlock;
 
   public PartitionCache() {
+    this.memoryBlock =
+        memoryConfig
+            .getPartitionCacheMemoryManager()
+            .exactAllocate("PartitionCache", MemoryBlockType.STATIC);
+    this.memoryBlock.allocate(this.memoryBlock.getTotalMemorySizeInBytes());
+    // TODO @spricoder: PartitionCache need to be controlled according to memory
     this.schemaPartitionCache =
         Caffeine.newBuilder().maximumSize(config.getPartitionCacheSize()).build();
     this.dataPartitionCache =
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/schema/DataNodeDevicePathCache.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/schema/DataNodeDevicePathCache.java
index 4fe88a9c24f..07293bc4ca3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/schema/DataNodeDevicePathCache.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/schema/DataNodeDevicePathCache.java
@@ -20,29 +20,38 @@
 package org.apache.iotdb.db.queryengine.plan.analyze.cache.schema;
 
 import org.apache.iotdb.commons.exception.IllegalPathException;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 
 import com.github.benmanes.caffeine.cache.Cache;
 import com.github.benmanes.caffeine.cache.Caffeine;
 import com.github.benmanes.caffeine.cache.Weigher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /** This cache is for reducing duplicated DeviceId PartialPath initialization in write process. */
 public class DataNodeDevicePathCache {
+  private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeDevicePathCache.class);
 
-  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
+  private final IMemoryBlock devicePathCacheMemoryBlock;
 
   private final Cache<String, PartialPath> devicePathCache;
 
   private DataNodeDevicePathCache() {
+    devicePathCacheMemoryBlock =
+        memoryConfig
+            .getDevicePathCacheMemoryManager()
+            .exactAllocate("DevicePathCache", MemoryBlockType.STATIC);
+    // TODO @spricoder: later we can find a way to get the byte size of cache
+    devicePathCacheMemoryBlock.allocate(devicePathCacheMemoryBlock.getTotalMemorySizeInBytes());
     devicePathCache =
         Caffeine.newBuilder()
-            .maximumWeight(
-                (long)
-                    (config.getAllocateMemoryForStorageEngine()
-                        * config.getWriteProportionForMemtable()
-                        * config.getDevicePathCacheProportion()))
+            .maximumWeight(devicePathCacheMemoryBlock.getTotalMemorySizeInBytes())
             .weigher(
                 (Weigher<String, PartialPath>) (key, val) -> (PartialPath.estimateSize(val) + 32))
             .build();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LocalExecutionPlanContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LocalExecutionPlanContext.java
index 09dc6fef44e..de4f99ff089 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LocalExecutionPlanContext.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LocalExecutionPlanContext.java
@@ -240,7 +240,8 @@ public class LocalExecutionPlanContext {
   }
 
   public long getMaxBytesOneHandleCanReserve() {
-    long maxBytesPerFI = IoTDBDescriptor.getInstance().getConfig().getMaxBytesPerFragmentInstance();
+    long maxBytesPerFI =
+        IoTDBDescriptor.getInstance().getMemoryConfig().getMaxBytesPerFragmentInstance();
     return exchangeSumNum == 0 ? maxBytesPerFI : maxBytesPerFI / exchangeSumNum;
   }
 
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LocalExecutionPlanner.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LocalExecutionPlanner.java
index f2f840043e7..735d225ccdd 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LocalExecutionPlanner.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LocalExecutionPlanner.java
@@ -19,7 +19,10 @@
 
 package org.apache.iotdb.db.queryengine.plan.planner;
 
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.path.IFullPath;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.protocol.session.IClientSession;
@@ -58,28 +61,31 @@ import static org.apache.iotdb.db.protocol.session.IClientSession.SqlDialect.TRE
 public class LocalExecutionPlanner {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(LocalExecutionPlanner.class);
-  private static final long ALLOCATE_MEMORY_FOR_OPERATORS;
+  private static final IMemoryBlock OPERATORS_MEMORY_BLOCK;
   private static final long MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD;
 
   public final Metadata metadata = new TableMetadataImpl();
 
   static {
     IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
-    ALLOCATE_MEMORY_FOR_OPERATORS = CONFIG.getAllocateMemoryForOperators();
+    DataNodeMemoryConfig MEMORY_CONFIG = IoTDBDescriptor.getInstance().getMemoryConfig();
+
+    OPERATORS_MEMORY_BLOCK =
+        MEMORY_CONFIG
+            .getOperatorsMemoryManager()
+            .exactAllocate("Operators", MemoryBlockType.DYNAMIC);
     MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD =
         (long)
-            ((ALLOCATE_MEMORY_FOR_OPERATORS) * (1.0 - CONFIG.getMaxAllocateMemoryRatioForLoad()));
+            ((OPERATORS_MEMORY_BLOCK.getTotalMemorySizeInBytes())
+                * (1.0 - CONFIG.getMaxAllocateMemoryRatioForLoad()));
   }
 
-  /** allocated memory for operator execution */
-  private long freeMemoryForOperators = ALLOCATE_MEMORY_FOR_OPERATORS;
-
   public long getFreeMemoryForOperators() {
-    return freeMemoryForOperators;
+    return OPERATORS_MEMORY_BLOCK.getFreeMemoryInBytes();
   }
 
   public long getFreeMemoryForLoadTsFile() {
-    return freeMemoryForOperators - MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD;
+    return OPERATORS_MEMORY_BLOCK.getFreeMemoryInBytes() - MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD;
   }
 
   public static LocalExecutionPlanner getInstance() {
@@ -176,7 +182,7 @@ public class LocalExecutionPlanner {
       throws MemoryNotEnoughException {
 
     // if it is disabled, just return
-    if (!IoTDBDescriptor.getInstance().getConfig().isEnableQueryMemoryEstimation()
+    if (!IoTDBDescriptor.getInstance().getMemoryConfig().isEnableQueryMemoryEstimation()
         && !IoTDBDescriptor.getInstance().getConfig().isQuotaEnable()) {
       return 0;
     }
@@ -185,38 +191,32 @@ public class LocalExecutionPlanner {
 
     QueryRelatedResourceMetricSet.getInstance().updateEstimatedMemory(estimatedMemorySize);
 
-    synchronized (this) {
-      if (estimatedMemorySize > freeMemoryForOperators) {
-        throw new MemoryNotEnoughException(
-            String.format(
-                "There is not enough memory to execute current fragment instance, "
-                    + "current remaining free memory is %dB, "
-                    + "estimated memory usage for current fragment instance is %dB",
-                freeMemoryForOperators, estimatedMemorySize));
-      } else {
-        freeMemoryForOperators -= estimatedMemorySize;
-        if (LOGGER.isDebugEnabled()) {
-          LOGGER.debug(
-              "[ConsumeMemory] consume: {}, current remaining memory: {}",
-              estimatedMemorySize,
-              freeMemoryForOperators);
-        }
+    if (OPERATORS_MEMORY_BLOCK.allocate(estimatedMemorySize)) {
+      if (LOGGER.isDebugEnabled()) {
+        LOGGER.debug(
+            "[ConsumeMemory] consume: {}, current remaining memory: {}",
+            estimatedMemorySize,
+            OPERATORS_MEMORY_BLOCK.getFreeMemoryInBytes());
       }
+    } else {
+      throw new MemoryNotEnoughException(
+          String.format(
+              "There is not enough memory to execute current fragment instance, "
+                  + "current remaining free memory is %dB, "
+                  + "estimated memory usage for current fragment instance is %dB",
+              OPERATORS_MEMORY_BLOCK.getFreeMemoryInBytes(), estimatedMemorySize));
     }
-
     stateMachine.addStateChangeListener(
         newState -> {
           if (newState.isDone()) {
             try (SetThreadName fragmentInstanceName =
                 new SetThreadName(stateMachine.getFragmentInstanceId().getFullId())) {
-              synchronized (this) {
-                this.freeMemoryForOperators += estimatedMemorySize;
-                if (LOGGER.isDebugEnabled()) {
-                  LOGGER.debug(
-                      "[ReleaseMemory] release: {}, current remaining memory: {}",
-                      estimatedMemorySize,
-                      freeMemoryForOperators);
-                }
+              OPERATORS_MEMORY_BLOCK.release(estimatedMemorySize);
+              if (LOGGER.isDebugEnabled()) {
+                LOGGER.debug(
+                    "[ReleaseMemory] release: {}, current remaining memory: {}",
+                    estimatedMemorySize,
+                    OPERATORS_MEMORY_BLOCK.getFreeMemoryInBytes());
               }
             }
           }
@@ -250,64 +250,62 @@ public class LocalExecutionPlanner {
   }
 
   public synchronized boolean forceAllocateFreeMemoryForOperators(long memoryInBytes) {
-    if (freeMemoryForOperators - memoryInBytes <= MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD) {
+    // TODO @spricoder: consider a better way
+    if (OPERATORS_MEMORY_BLOCK.getFreeMemoryInBytes() - memoryInBytes
+        <= MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD) {
       return false;
     } else {
-      freeMemoryForOperators -= memoryInBytes;
+      OPERATORS_MEMORY_BLOCK.forceAllocateWithoutLimitation(memoryInBytes);
       return true;
     }
   }
 
   public synchronized long tryAllocateFreeMemoryForOperators(long memoryInBytes) {
-    if (freeMemoryForOperators - memoryInBytes <= MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD) {
-      long result = freeMemoryForOperators - MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD;
-      freeMemoryForOperators = MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD;
+    if (OPERATORS_MEMORY_BLOCK.getFreeMemoryInBytes() - memoryInBytes
+        <= MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD) {
+      long result =
+          OPERATORS_MEMORY_BLOCK.getFreeMemoryInBytes() - MIN_REST_MEMORY_FOR_QUERY_AFTER_LOAD;
+      OPERATORS_MEMORY_BLOCK.forceAllocateWithoutLimitation(result);
       return result;
     } else {
-      freeMemoryForOperators -= memoryInBytes;
+      OPERATORS_MEMORY_BLOCK.forceAllocateWithoutLimitation(memoryInBytes);
       return memoryInBytes;
     }
   }
 
-  public synchronized void reserveFromFreeMemoryForOperators(
+  public void reserveFromFreeMemoryForOperators(
       final long memoryInBytes,
       final long reservedBytes,
       final String queryId,
       final String contextHolder) {
-    if (memoryInBytes > freeMemoryForOperators) {
+    if (OPERATORS_MEMORY_BLOCK.allocate(memoryInBytes)) {
+      if (LOGGER.isDebugEnabled()) {
+        LOGGER.debug(
+            "[ConsumeMemory] consume: {}, current remaining memory: {}",
+            memoryInBytes,
+            OPERATORS_MEMORY_BLOCK.getFreeMemoryInBytes());
+      }
+    } else {
       throw new MemoryNotEnoughException(
           String.format(
               "There is not enough memory for Query %s, the contextHolder is %s,"
                   + "current remaining free memory is %dB, "
                   + "already reserved memory for this context in total is %dB, "
                   + "the memory requested this time is %dB",
-              queryId, contextHolder, freeMemoryForOperators, reservedBytes, memoryInBytes));
-    } else {
-      freeMemoryForOperators -= memoryInBytes;
-      if (LOGGER.isDebugEnabled()) {
-        LOGGER.debug(
-            "[ConsumeMemory] consume: {}, current remaining memory: {}",
-            memoryInBytes,
-            freeMemoryForOperators);
-      }
+              queryId,
+              contextHolder,
+              OPERATORS_MEMORY_BLOCK.getFreeMemoryInBytes(),
+              reservedBytes,
+              memoryInBytes));
     }
   }
 
-  public synchronized void releaseToFreeMemoryForOperators(final long memoryInBytes) {
-    freeMemoryForOperators += memoryInBytes;
-
-    if (freeMemoryForOperators > ALLOCATE_MEMORY_FOR_OPERATORS) {
-      LOGGER.error(
-          "The free memory {} is more than allocated memory {}, last released memory: {}",
-          freeMemoryForOperators,
-          ALLOCATE_MEMORY_FOR_OPERATORS,
-          memoryInBytes);
-      freeMemoryForOperators = ALLOCATE_MEMORY_FOR_OPERATORS;
-    }
+  public void releaseToFreeMemoryForOperators(final long memoryInBytes) {
+    OPERATORS_MEMORY_BLOCK.release(memoryInBytes);
   }
 
   public long getAllocateMemoryForOperators() {
-    return ALLOCATE_MEMORY_FOR_OPERATORS;
+    return OPERATORS_MEMORY_BLOCK.getTotalMemorySizeInBytes();
   }
 
   private static class InstanceHolder {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCache.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCache.java
index 579f8192f4b..1f33478c485 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCache.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCache.java
@@ -20,11 +20,14 @@
 package org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.cache;
 
 import org.apache.iotdb.commons.exception.IllegalPathException;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.path.ExtendedPartialPath;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.path.PathPatternUtil;
 import org.apache.iotdb.commons.service.metric.MetricService;
 import org.apache.iotdb.commons.utils.PathUtils;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.queryengine.common.schematree.DeviceSchemaInfo;
@@ -84,6 +87,8 @@ import static org.apache.iotdb.commons.conf.IoTDBConstant.ONE_LEVEL_PATH_WILDCAR
 public class TableDeviceSchemaCache {
 
   private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private static final Logger logger = LoggerFactory.getLogger(TableDeviceSchemaCache.class);
 
   /**
@@ -100,17 +105,23 @@ public class TableDeviceSchemaCache {
 
   private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock(false);
 
+  private final IMemoryBlock memoryBlock;
+
   private TableDeviceSchemaCache() {
+    memoryBlock =
+        memoryConfig
+            .getSchemaCacheMemoryManager()
+            .exactAllocate("TableDeviceSchemaCache", MemoryBlockType.STATIC);
     dualKeyCache =
         new DualKeyCacheBuilder<TableId, IDeviceID, TableDeviceCacheEntry>()
             .cacheEvictionPolicy(
                 DualKeyCachePolicy.valueOf(config.getDataNodeSchemaCacheEvictionPolicy()))
-            .memoryCapacity(config.getAllocateMemoryForSchemaCache())
+            .memoryCapacity(memoryBlock.getTotalMemorySizeInBytes())
             .firstKeySizeComputer(TableId::estimateSize)
             .secondKeySizeComputer(deviceID -> (int) deviceID.ramBytesUsed())
             .valueSizeComputer(TableDeviceCacheEntry::estimateSize)
             .build();
-
+    memoryBlock.allocate(memoryBlock.getTotalMemorySizeInBytes());
     MetricService.getInstance().addMetricSet(new TableDeviceSchemaCacheMetrics(this));
   }
 
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/metric/SchemaEngineCachedMetric.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/metric/SchemaEngineCachedMetric.java
index 99120433d76..8620cda8265 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/metric/SchemaEngineCachedMetric.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/metric/SchemaEngineCachedMetric.java
@@ -52,7 +52,10 @@ public class SchemaEngineCachedMetric implements ISchemaEngineMetric {
     schemaEngineMemMetric.bindTo(metricService);
     metricService.gauge(
         (long)
-            (IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForSchemaRegion()
+            (IoTDBDescriptor.getInstance()
+                    .getMemoryConfig()
+                    .getSchemaRegionMemoryManager()
+                    .getTotalMemorySizeInBytes()
                 * ReleaseFlushStrategySizeBasedImpl.RELEASE_THRESHOLD_RATIO),
         Metric.SCHEMA_ENGINE.toString(),
         MetricLevel.IMPORTANT,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/MemSchemaEngineStatistics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/MemSchemaEngineStatistics.java
index faf0546df70..c50dd62ecea 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/MemSchemaEngineStatistics.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/MemSchemaEngineStatistics.java
@@ -19,6 +19,8 @@
 
 package org.apache.iotdb.db.schemaengine.rescon;
 
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.schemaengine.SchemaEngine;
 import org.apache.iotdb.db.schemaengine.template.ClusterTemplateManager;
@@ -34,14 +36,15 @@ import java.util.concurrent.atomic.AtomicLong;
 public class MemSchemaEngineStatistics implements ISchemaEngineStatistics {
 
   private static final Logger logger = LoggerFactory.getLogger(MemSchemaEngineStatistics.class);
-
   // Total size of schema region
-  private final long memoryCapacity =
-      IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForSchemaRegion();
+  private final IMemoryBlock memoryBlock =
+      IoTDBDescriptor.getInstance()
+          .getMemoryConfig()
+          .getSchemaRegionMemoryManager()
+          .exactAllocate("SchemaRegion", MemoryBlockType.DYNAMIC);
   private final ClusterTemplateManager clusterTemplateManager =
       ClusterTemplateManager.getInstance();
 
-  protected final AtomicLong memoryUsage = new AtomicLong(0);
   private final AtomicLong totalMeasurementNumber = new AtomicLong(0);
   private final AtomicLong totalViewNumber = new AtomicLong(0);
   private final AtomicLong totalDeviceNumber = new AtomicLong(0);
@@ -61,28 +64,31 @@ public class MemSchemaEngineStatistics implements ISchemaEngineStatistics {
 
   @Override
   public boolean isExceedCapacity() {
-    return memoryUsage.get() > memoryCapacity;
+    return memoryBlock.getUsedMemoryInBytes() > memoryBlock.getTotalMemorySizeInBytes();
   }
 
   @Override
   public long getMemoryCapacity() {
-    return memoryCapacity;
+    return memoryBlock.getTotalMemorySizeInBytes();
   }
 
   @Override
   public long getMemoryUsage() {
-    return memoryUsage.get();
+    return memoryBlock.getUsedMemoryInBytes();
   }
 
   public void requestMemory(final long size) {
-    memoryUsage.addAndGet(size);
-    if (memoryUsage.get() >= memoryCapacity) {
+    memoryBlock.forceAllocateWithoutLimitation(size);
+    if (memoryBlock.getUsedMemoryInBytes() >= memoryBlock.getTotalMemorySizeInBytes()) {
       synchronized (allowToCreateNewSeriesLock) {
-        if (allowToCreateNewSeries && memoryUsage.get() >= memoryCapacity) {
+        if (allowToCreateNewSeries
+            && memoryBlock.getUsedMemoryInBytes() >= memoryBlock.getTotalMemorySizeInBytes()) {
           if (needLog) {
-            logger.warn("Current series memory {} is too large...", memoryUsage);
+            logger.warn(
+                "Current series memory {} is too large...", memoryBlock.getUsedMemoryInBytes());
           } else {
-            logger.debug("Current series memory {} is too large...", memoryUsage);
+            logger.debug(
+                "Current series memory {} is too large...", memoryBlock.getUsedMemoryInBytes());
           }
           allowToCreateNewSeries = false;
         }
@@ -91,19 +97,20 @@ public class MemSchemaEngineStatistics implements ISchemaEngineStatistics {
   }
 
   public void releaseMemory(final long size) {
-    memoryUsage.addAndGet(-size);
-    if (memoryUsage.get() < memoryCapacity) {
+    memoryBlock.release(size);
+    if (memoryBlock.getUsedMemoryInBytes() < memoryBlock.getTotalMemorySizeInBytes()) {
       synchronized (allowToCreateNewSeriesLock) {
-        if (!allowToCreateNewSeries && memoryUsage.get() < memoryCapacity) {
+        if (!allowToCreateNewSeries
+            && memoryBlock.getUsedMemoryInBytes() < memoryBlock.getTotalMemorySizeInBytes()) {
           if (needLog) {
             logger.info(
                 "Current series memory {} come back to normal level, total series number is {}.",
-                memoryUsage,
+                memoryBlock.getUsedMemoryInBytes(),
                 totalMeasurementNumber.get() + totalViewNumber.get());
           } else {
             logger.debug(
                 "Current series memory {} come back to normal level, total series number is {}.",
-                memoryUsage,
+                memoryBlock.getUsedMemoryInBytes(),
                 totalMeasurementNumber.get() + totalViewNumber.get());
           }
           allowToCreateNewSeries = true;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/memcontrol/ReleaseFlushStrategySizeBasedImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/memcontrol/ReleaseFlushStrategySizeBasedImpl.java
index c0be7203f2a..4343ed0fc68 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/memcontrol/ReleaseFlushStrategySizeBasedImpl.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/memcontrol/ReleaseFlushStrategySizeBasedImpl.java
@@ -31,7 +31,11 @@ public class ReleaseFlushStrategySizeBasedImpl implements IReleaseFlushStrategy
 
   public ReleaseFlushStrategySizeBasedImpl(CachedSchemaEngineStatistics engineStatistics) {
     this.engineStatistics = engineStatistics;
-    long capacity = IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForSchemaRegion();
+    long capacity =
+        IoTDBDescriptor.getInstance()
+            .getMemoryConfig()
+            .getSchemaRegionMemoryManager()
+            .getTotalMemorySizeInBytes();
     this.releaseThreshold = (long) (capacity * RELEASE_THRESHOLD_RATIO);
   }
 
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/CompactionMetrics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/CompactionMetrics.java
index 631f3430535..75372f0c387 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/CompactionMetrics.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/CompactionMetrics.java
@@ -632,7 +632,7 @@ public class CompactionMetrics implements IMetricSet {
         Metric.COMPACTION_TASK_MEMORY_DISTRIBUTION.toString(),
         MetricLevel.IMPORTANT,
         this,
-        metrics -> SystemInfo.getInstance().getCompactionMemoryCost().get(),
+        metrics -> SystemInfo.getInstance().getCompactionMemoryBlock().getUsedMemoryInBytes(),
         Tag.NAME.toString(),
         "total_usage");
     metricService.createAutoGauge(
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/WritingMetrics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/WritingMetrics.java
index 770e6c485ea..2e201e0c211 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/WritingMetrics.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/WritingMetrics.java
@@ -269,7 +269,7 @@ public class WritingMetrics implements IMetricSet {
         Metric.WAL_QUEUE_MEM_COST.toString(),
         MetricLevel.IMPORTANT,
         systemInfo,
-        SystemInfo::getCurrentWalQueueMemoryCost,
+        (s) -> s.getWalBufferQueueMemoryBlock().getUsedMemoryInBytes(),
         Tag.NAME.toString(),
         WAL_QUEUE_CURRENT_MEM_COST);
   }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/ConsensusMemoryMetrics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/ConsensusMemoryMetrics.java
index b3f108892e7..49108cef8c6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/ConsensusMemoryMetrics.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/ConsensusMemoryMetrics.java
@@ -19,9 +19,10 @@
 
 package org.apache.iotdb.db.service.metrics.memory;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.commons.service.metric.enums.Metric;
 import org.apache.iotdb.commons.service.metric.enums.Tag;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.metrics.AbstractMetricService;
 import org.apache.iotdb.metrics.metricsets.IMetricSet;
@@ -29,28 +30,40 @@ import org.apache.iotdb.metrics.utils.MetricLevel;
 import org.apache.iotdb.metrics.utils.MetricType;
 
 public class ConsensusMemoryMetrics implements IMetricSet {
-  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private static final String CONSENSUS = "Consensus";
 
   @Override
   public void bindTo(AbstractMetricService metricService) {
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            CONSENSUS,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[1])
-        .set(config.getAllocateMemoryForConsensus());
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getConsensusMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        CONSENSUS,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getConsensusMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        CONSENSUS,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
   }
 
   @Override
   public void unbindFrom(AbstractMetricService metricService) {
     metricService.remove(
-        MetricType.GAUGE,
+        MetricType.AUTO_GAUGE,
         Metric.MEMORY_THRESHOLD_SIZE.toString(),
         Tag.NAME.toString(),
         CONSENSUS,
@@ -58,6 +71,15 @@ public class ConsensusMemoryMetrics implements IMetricSet {
         GlobalMemoryMetrics.ON_HEAP,
         Tag.LEVEL.toString(),
         GlobalMemoryMetrics.LEVELS[1]);
+    metricService.remove(
+        MetricType.AUTO_GAUGE,
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        Tag.NAME.toString(),
+        CONSENSUS,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
   }
 
   public static ConsensusMemoryMetrics getInstance() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/GlobalMemoryMetrics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/GlobalMemoryMetrics.java
index cca3f46f1d8..ca63b231aaa 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/GlobalMemoryMetrics.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/GlobalMemoryMetrics.java
@@ -19,70 +19,57 @@
 
 package org.apache.iotdb.db.service.metrics.memory;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.commons.service.metric.enums.Metric;
 import org.apache.iotdb.commons.service.metric.enums.Tag;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.storageengine.rescon.memory.SystemInfo;
 import org.apache.iotdb.metrics.AbstractMetricService;
 import org.apache.iotdb.metrics.metricsets.IMetricSet;
 import org.apache.iotdb.metrics.utils.MetricLevel;
 import org.apache.iotdb.metrics.utils.MetricType;
 
 import java.util.Arrays;
-import java.util.Collections;
 
 public class GlobalMemoryMetrics implements IMetricSet {
-  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-  private static final SystemInfo systemInfo = SystemInfo.getInstance();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
 
   private static final String TOTAL = "Total";
   public static final String ON_HEAP = "OnHeap";
   public static final String OFF_HEAP = "OffHeap";
   public static final String[] LEVELS = {"0", "1", "2", "3", "4"};
 
-  private static final String DIRECT_BUFFER = "DirectBuffer";
-
   @Override
   public void bindTo(AbstractMetricService metricService) {
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            TOTAL,
-            Tag.TYPE.toString(),
-            ON_HEAP,
-            Tag.LEVEL.toString(),
-            LEVELS[0])
-        .set(Runtime.getRuntime().maxMemory());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            TOTAL,
-            Tag.TYPE.toString(),
-            OFF_HEAP,
-            Tag.LEVEL.toString(),
-            LEVELS[0])
-        .set(config.getMaxOffHeapMemoryBytes());
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getOnHeapMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        TOTAL,
+        Tag.TYPE.toString(),
+        ON_HEAP,
+        Tag.LEVEL.toString(),
+        LEVELS[0]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getOffHeapMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        TOTAL,
+        Tag.TYPE.toString(),
+        OFF_HEAP,
+        Tag.LEVEL.toString(),
+        LEVELS[0]);
     StorageEngineMemoryMetrics.getInstance().bindTo(metricService);
     QueryEngineMemoryMetrics.getInstance().bindTo(metricService);
     SchemaEngineMemoryMetrics.getInstance().bindTo(metricService);
     ConsensusMemoryMetrics.getInstance().bindTo(metricService);
     StreamEngineMemoryMetrics.getInstance().bindTo(metricService);
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            DIRECT_BUFFER,
-            Tag.TYPE.toString(),
-            OFF_HEAP,
-            Tag.LEVEL.toString(),
-            LEVELS[1])
-        .set(systemInfo.getTotalDirectBufferMemorySizeLimit());
+    OffHeapMemoryMetrics.getInstance().bindTo(metricService);
   }
 
   @Override
@@ -91,7 +78,7 @@ public class GlobalMemoryMetrics implements IMetricSet {
         .forEach(
             type -> {
               metricService.remove(
-                  MetricType.GAUGE,
+                  MetricType.AUTO_GAUGE,
                   Metric.MEMORY_THRESHOLD_SIZE.toString(),
                   Tag.NAME.toString(),
                   TOTAL,
@@ -105,18 +92,7 @@ public class GlobalMemoryMetrics implements IMetricSet {
     SchemaEngineMemoryMetrics.getInstance().unbindFrom(metricService);
     ConsensusMemoryMetrics.getInstance().unbindFrom(metricService);
     StreamEngineMemoryMetrics.getInstance().unbindFrom(metricService);
-    Collections.singletonList(DIRECT_BUFFER)
-        .forEach(
-            name ->
-                metricService.remove(
-                    MetricType.GAUGE,
-                    Metric.MEMORY_THRESHOLD_SIZE.toString(),
-                    Tag.NAME.toString(),
-                    name,
-                    Tag.TYPE.toString(),
-                    OFF_HEAP,
-                    Tag.LEVEL.toString(),
-                    LEVELS[1]));
+    OffHeapMemoryMetrics.getInstance().unbindFrom(metricService);
   }
 
   public static GlobalMemoryMetrics getInstance() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/OffHeapMemoryMetrics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/OffHeapMemoryMetrics.java
new file mode 100644
index 00000000000..ae03c5de9fe
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/OffHeapMemoryMetrics.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.service.metrics.memory;
+
+import org.apache.iotdb.commons.memory.MemoryManager;
+import org.apache.iotdb.commons.service.metric.enums.Metric;
+import org.apache.iotdb.commons.service.metric.enums.Tag;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.metrics.AbstractMetricService;
+import org.apache.iotdb.metrics.metricsets.IMetricSet;
+import org.apache.iotdb.metrics.utils.MetricLevel;
+import org.apache.iotdb.metrics.utils.MetricType;
+
+import java.util.Collections;
+
+public class OffHeapMemoryMetrics implements IMetricSet {
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
+
+  private static final String DIRECT_BUFFER = "DirectBuffer";
+
+  @Override
+  public void bindTo(AbstractMetricService metricService) {
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getDirectBufferMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        DIRECT_BUFFER,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.OFF_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getDirectBufferMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        DIRECT_BUFFER,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.OFF_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
+  }
+
+  @Override
+  public void unbindFrom(AbstractMetricService metricService) {
+    Collections.singletonList(DIRECT_BUFFER)
+        .forEach(
+            name -> {
+              metricService.remove(
+                  MetricType.AUTO_GAUGE,
+                  Metric.MEMORY_THRESHOLD_SIZE.toString(),
+                  Tag.NAME.toString(),
+                  name,
+                  Tag.TYPE.toString(),
+                  GlobalMemoryMetrics.OFF_HEAP,
+                  Tag.LEVEL.toString(),
+                  GlobalMemoryMetrics.LEVELS[1]);
+              metricService.remove(
+                  MetricType.AUTO_GAUGE,
+                  Metric.MEMORY_ACTUAL_SIZE.toString(),
+                  Tag.NAME.toString(),
+                  name,
+                  Tag.TYPE.toString(),
+                  GlobalMemoryMetrics.OFF_HEAP,
+                  Tag.LEVEL.toString(),
+                  GlobalMemoryMetrics.LEVELS[1]);
+            });
+  }
+
+  public static OffHeapMemoryMetrics getInstance() {
+    return OffHeapMemoryMetrics.OffHeapMemoryMetricsHolder.INSTANCE;
+  }
+
+  private static class OffHeapMemoryMetricsHolder {
+
+    private static final OffHeapMemoryMetrics INSTANCE = new OffHeapMemoryMetrics();
+
+    private OffHeapMemoryMetricsHolder() {}
+  }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/QueryEngineMemoryMetrics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/QueryEngineMemoryMetrics.java
index 67538646525..23fa883954c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/QueryEngineMemoryMetrics.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/QueryEngineMemoryMetrics.java
@@ -19,9 +19,10 @@
 
 package org.apache.iotdb.db.service.metrics.memory;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.commons.service.metric.enums.Metric;
 import org.apache.iotdb.commons.service.metric.enums.Tag;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.metrics.AbstractMetricService;
 import org.apache.iotdb.metrics.metricsets.IMetricSet;
@@ -31,7 +32,8 @@ import org.apache.iotdb.metrics.utils.MetricType;
 import java.util.Arrays;
 
 public class QueryEngineMemoryMetrics implements IMetricSet {
-  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private static final String QUERY_ENGINE = "QueryEngine";
   private static final String QUERY_ENGINE_BLOOM_FILTER_CACHE = "QueryEngine-BloomFilterCache";
   private static final String QUERY_ENGINE_CHUNK_CACHE = "QueryEngine-ChunkCache";
@@ -44,100 +46,167 @@ public class QueryEngineMemoryMetrics implements IMetricSet {
 
   @Override
   public void bindTo(AbstractMetricService metricService) {
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            QUERY_ENGINE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[1])
-        .set(config.getAllocateMemoryForRead());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            QUERY_ENGINE_BLOOM_FILTER_CACHE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(config.getAllocateMemoryForBloomFilterCache());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            QUERY_ENGINE_CHUNK_CACHE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(config.getAllocateMemoryForChunkCache());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            QUERY_ENGINE_TIME_SERIES_METADATA_CACHE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(config.getAllocateMemoryForTimeSeriesMetaDataCache());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            QUERY_ENGINE_OPERATORS,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(config.getAllocateMemoryForOperators());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            QUERY_ENGINE_DATA_EXCHANGE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(config.getAllocateMemoryForDataExchange());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            QUERY_ENGINE_TIME_INDEX,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(config.getAllocateMemoryForTimeIndex());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            QUERY_ENGINE_COORDINATOR,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(config.getAllocateMemoryForCoordinator());
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getQueryEngineMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getBloomFilterCacheMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_BLOOM_FILTER_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getBloomFilterCacheMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_BLOOM_FILTER_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getChunkCacheMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_CHUNK_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getChunkCacheMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_CHUNK_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getTimeSeriesMetaDataCacheMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_TIME_SERIES_METADATA_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getTimeSeriesMetaDataCacheMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_TIME_SERIES_METADATA_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getOperatorsMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_OPERATORS,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getOperatorsMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_OPERATORS,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getDataExchangeMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_DATA_EXCHANGE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getDataExchangeMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_DATA_EXCHANGE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getTimeIndexMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_TIME_INDEX,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getTimeIndexMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_TIME_INDEX,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getCoordinatorMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        QUERY_ENGINE_COORDINATOR,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    // TODO @spricoder: CoordinatorMemoryManager are not used
   }
 
   @Override
   public void unbindFrom(AbstractMetricService metricService) {
     metricService.remove(
-        MetricType.GAUGE,
+        MetricType.AUTO_GAUGE,
         Metric.MEMORY_THRESHOLD_SIZE.toString(),
         Tag.NAME.toString(),
         QUERY_ENGINE,
@@ -154,16 +223,26 @@ public class QueryEngineMemoryMetrics implements IMetricSet {
             QUERY_ENGINE_TIME_INDEX,
             QUERY_ENGINE_COORDINATOR)
         .forEach(
-            name ->
-                metricService.remove(
-                    MetricType.GAUGE,
-                    Metric.MEMORY_THRESHOLD_SIZE.toString(),
-                    Tag.NAME.toString(),
-                    name,
-                    Tag.TYPE.toString(),
-                    GlobalMemoryMetrics.ON_HEAP,
-                    Tag.LEVEL.toString(),
-                    GlobalMemoryMetrics.LEVELS[2]));
+            name -> {
+              metricService.remove(
+                  MetricType.AUTO_GAUGE,
+                  Metric.MEMORY_THRESHOLD_SIZE.toString(),
+                  Tag.NAME.toString(),
+                  name,
+                  Tag.TYPE.toString(),
+                  GlobalMemoryMetrics.ON_HEAP,
+                  Tag.LEVEL.toString(),
+                  GlobalMemoryMetrics.LEVELS[2]);
+              metricService.remove(
+                  MetricType.AUTO_GAUGE,
+                  Metric.MEMORY_ACTUAL_SIZE.toString(),
+                  Tag.NAME.toString(),
+                  name,
+                  Tag.TYPE.toString(),
+                  GlobalMemoryMetrics.ON_HEAP,
+                  Tag.LEVEL.toString(),
+                  GlobalMemoryMetrics.LEVELS[2]);
+            });
   }
 
   public static QueryEngineMemoryMetrics getInstance() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/SchemaEngineMemoryMetrics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/SchemaEngineMemoryMetrics.java
index 5b075726363..e47cbdf41e7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/SchemaEngineMemoryMetrics.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/SchemaEngineMemoryMetrics.java
@@ -19,9 +19,10 @@
 
 package org.apache.iotdb.db.service.metrics.memory;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.commons.service.metric.enums.Metric;
 import org.apache.iotdb.commons.service.metric.enums.Tag;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.metrics.AbstractMetricService;
 import org.apache.iotdb.metrics.metricsets.IMetricSet;
@@ -31,7 +32,8 @@ import org.apache.iotdb.metrics.utils.MetricType;
 import java.util.Arrays;
 
 public class SchemaEngineMemoryMetrics implements IMetricSet {
-  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private static final String SCHEMA_ENGINE = "SchemaEngine";
   private static final String SCHEMA_ENGINE_SCHEMA_REGION = "SchemaEngine-SchemaRegion";
   private static final String SCHEMA_ENGINE_SCHEMA_CACHE = "SchemaEngine-SchemaCache";
@@ -39,56 +41,89 @@ public class SchemaEngineMemoryMetrics implements IMetricSet {
 
   @Override
   public void bindTo(AbstractMetricService metricService) {
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            SCHEMA_ENGINE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[1])
-        .set(config.getAllocateMemoryForSchema());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            SCHEMA_ENGINE_SCHEMA_REGION,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(config.getAllocateMemoryForSchemaRegion());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            SCHEMA_ENGINE_SCHEMA_CACHE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(config.getAllocateMemoryForSchemaCache());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            SCHEMA_ENGINE_PARTITION_CACHE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(config.getAllocateMemoryForPartitionCache());
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getSchemaEngineMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        SCHEMA_ENGINE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getSchemaRegionMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        SCHEMA_ENGINE_SCHEMA_REGION,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getSchemaRegionMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        SCHEMA_ENGINE_SCHEMA_REGION,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getSchemaCacheMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        SCHEMA_ENGINE_SCHEMA_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getSchemaCacheMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        SCHEMA_ENGINE_SCHEMA_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getPartitionCacheMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        SCHEMA_ENGINE_PARTITION_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getPartitionCacheMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        SCHEMA_ENGINE_PARTITION_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
   }
 
   @Override
   public void unbindFrom(AbstractMetricService metricService) {
     metricService.remove(
-        MetricType.GAUGE,
+        MetricType.AUTO_GAUGE,
         Metric.MEMORY_THRESHOLD_SIZE.toString(),
         Tag.NAME.toString(),
         SCHEMA_ENGINE,
@@ -99,16 +134,26 @@ public class SchemaEngineMemoryMetrics implements IMetricSet {
     Arrays.asList(
             SCHEMA_ENGINE_SCHEMA_REGION, SCHEMA_ENGINE_SCHEMA_CACHE, SCHEMA_ENGINE_PARTITION_CACHE)
         .forEach(
-            name ->
-                metricService.remove(
-                    MetricType.GAUGE,
-                    Metric.MEMORY_THRESHOLD_SIZE.toString(),
-                    Tag.NAME.toString(),
-                    name,
-                    Tag.TYPE.toString(),
-                    GlobalMemoryMetrics.ON_HEAP,
-                    Tag.LEVEL.toString(),
-                    GlobalMemoryMetrics.LEVELS[2]));
+            name -> {
+              metricService.remove(
+                  MetricType.AUTO_GAUGE,
+                  Metric.MEMORY_THRESHOLD_SIZE.toString(),
+                  Tag.NAME.toString(),
+                  name,
+                  Tag.TYPE.toString(),
+                  GlobalMemoryMetrics.ON_HEAP,
+                  Tag.LEVEL.toString(),
+                  GlobalMemoryMetrics.LEVELS[2]);
+              metricService.remove(
+                  MetricType.AUTO_GAUGE,
+                  Metric.MEMORY_ACTUAL_SIZE.toString(),
+                  Tag.NAME.toString(),
+                  name,
+                  Tag.TYPE.toString(),
+                  GlobalMemoryMetrics.ON_HEAP,
+                  Tag.LEVEL.toString(),
+                  GlobalMemoryMetrics.LEVELS[2]);
+            });
   }
 
   public static SchemaEngineMemoryMetrics getInstance() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/StorageEngineMemoryMetrics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/StorageEngineMemoryMetrics.java
index 2fd726272d5..82a020de54f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/StorageEngineMemoryMetrics.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/StorageEngineMemoryMetrics.java
@@ -19,9 +19,10 @@
 
 package org.apache.iotdb.db.service.metrics.memory;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.commons.service.metric.enums.Metric;
 import org.apache.iotdb.commons.service.metric.enums.Tag;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.metrics.AbstractMetricService;
 import org.apache.iotdb.metrics.metricsets.IMetricSet;
@@ -31,126 +32,44 @@ import org.apache.iotdb.metrics.utils.MetricType;
 import java.util.Arrays;
 
 public class StorageEngineMemoryMetrics implements IMetricSet {
-  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private static final String STORAGE_ENGINE = "StorageEngine";
   private static final String STORAGE_ENGINE_WRITE = "StorageEngine-Write";
   private static final String STORAGE_ENGINE_WRITE_MEMTABLE = "StorageEngine-Write-Memtable";
-  private static final String STORAGE_ENGINE_WRITE_MEMTABLE_CACHE =
+  private static final String STORAGE_ENGINE_WRITE_MEMTABLE_DEVICE_PATH_CACHE =
       "StorageEngine-Write-Memtable-DevicePathCache";
   private static final String STORAGE_ENGINE_WRITE_MEMTABLE_BUFFERED_ARRAYS =
       "StorageEngine-Write-Memtable-BufferedArrays";
+  private static final String STORAGE_ENGINE_WRITE_MEMTABLE_WAL_BUFFER_QUEUE =
+      "StorageEngine-Write-Memtable-WalBufferQueue";
   private static final String STORAGE_ENGINE_WRITE_TIME_PARTITION_INFO =
       "StorageEngine-Write-TimePartitionInfo";
   private static final String STORAGE_ENGINE_COMPACTION = "StorageEngine-Compaction";
 
   @Override
   public void bindTo(AbstractMetricService metricService) {
-    long storageEngineSize = config.getAllocateMemoryForStorageEngine();
-    // Total memory size of storage engine
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            STORAGE_ENGINE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[1])
-        .set(storageEngineSize);
-    // The memory of storage engine divided into Write and Compaction
-    long writeSize =
-        (long)
-            (config.getAllocateMemoryForStorageEngine() * (1 - config.getCompactionProportion()));
-    long compactionSize = storageEngineSize - writeSize;
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            STORAGE_ENGINE_WRITE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(writeSize);
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            STORAGE_ENGINE_COMPACTION,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[2])
-        .set(compactionSize);
-    // The write memory of storage engine divided into MemTable and TimePartitionInfo
-    long memtableSize =
-        (long)
-            (config.getAllocateMemoryForStorageEngine() * config.getWriteProportionForMemtable());
-    long timePartitionInfoSize = config.getAllocateMemoryForTimePartitionInfo();
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            STORAGE_ENGINE_WRITE_MEMTABLE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[3])
-        .set(memtableSize);
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            STORAGE_ENGINE_WRITE_TIME_PARTITION_INFO,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[3])
-        .set(timePartitionInfoSize);
-    // The memtable memory of storage engine contain DataNodeDevicePathCache (NOTICE: This part of
-    // memory is not divided)
-    long dataNodeDevicePathCacheSize =
-        (long)
-            (config.getAllocateMemoryForStorageEngine()
-                * config.getWriteProportionForMemtable()
-                * config.getDevicePathCacheProportion());
-    long bufferedArraySize =
-        (long)
-            (config.getAllocateMemoryForStorageEngine()
-                * config.getBufferedArraysMemoryProportion());
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            STORAGE_ENGINE_WRITE_MEMTABLE_CACHE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[4])
-        .set(dataNodeDevicePathCacheSize);
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            STORAGE_ENGINE_WRITE_MEMTABLE_BUFFERED_ARRAYS,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[4])
-        .set(bufferedArraySize);
+    // total memory of storage engine
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getStorageEngineMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
+    bindStorageEngineDividedMetrics(metricService);
+    bindWriteDividedMetrics(metricService);
+    bindMemtableDividedMetrics(metricService);
   }
 
   @Override
   public void unbindFrom(AbstractMetricService metricService) {
     metricService.remove(
-        MetricType.GAUGE,
+        MetricType.AUTO_GAUGE,
         Metric.MEMORY_THRESHOLD_SIZE.toString(),
         Tag.NAME.toString(),
         STORAGE_ENGINE,
@@ -158,23 +77,120 @@ public class StorageEngineMemoryMetrics implements IMetricSet {
         GlobalMemoryMetrics.ON_HEAP,
         Tag.LEVEL.toString(),
         GlobalMemoryMetrics.LEVELS[1]);
+    unbindStorageEngineDividedMetrics(metricService);
+    unbindWriteDividedMetric(metricService);
+    unbindMemtableDividedMetrics(metricService);
+  }
+
+  // region Storage Engine Divided Memory Metrics
+  private void bindStorageEngineDividedMetrics(AbstractMetricService metricService) {
+    // The memory of storage engine divided into write and compaction
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getWriteMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_WRITE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getCompactionMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_COMPACTION,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getCompactionMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_COMPACTION,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[2]);
+  }
+
+  private void unbindStorageEngineDividedMetrics(AbstractMetricService metricService) {
     Arrays.asList(STORAGE_ENGINE_WRITE, STORAGE_ENGINE_COMPACTION)
         .forEach(
-            name ->
-                metricService.remove(
-                    MetricType.GAUGE,
-                    Metric.MEMORY_THRESHOLD_SIZE.toString(),
-                    Tag.NAME.toString(),
-                    name,
-                    Tag.TYPE.toString(),
-                    GlobalMemoryMetrics.ON_HEAP,
-                    Tag.LEVEL.toString(),
-                    GlobalMemoryMetrics.LEVELS[2]));
+            name -> {
+              metricService.remove(
+                  MetricType.AUTO_GAUGE,
+                  Metric.MEMORY_THRESHOLD_SIZE.toString(),
+                  Tag.NAME.toString(),
+                  name,
+                  Tag.TYPE.toString(),
+                  GlobalMemoryMetrics.ON_HEAP,
+                  Tag.LEVEL.toString(),
+                  GlobalMemoryMetrics.LEVELS[2]);
+              metricService.remove(
+                  MetricType.AUTO_GAUGE,
+                  Metric.MEMORY_ACTUAL_SIZE.toString(),
+                  Tag.NAME.toString(),
+                  name,
+                  Tag.TYPE.toString(),
+                  GlobalMemoryMetrics.ON_HEAP,
+                  Tag.LEVEL.toString(),
+                  GlobalMemoryMetrics.LEVELS[2]);
+            });
+  }
+
+  // endregion
+
+  // region Write Divided Memory Metrics
+  private void bindWriteDividedMetrics(AbstractMetricService metricService) {
+    // The memory of write divided into memtable and compaction
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getMemtableMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_WRITE_MEMTABLE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[3]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getTimePartitionInfoMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_WRITE_TIME_PARTITION_INFO,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[3]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getTimePartitionInfoMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_WRITE_TIME_PARTITION_INFO,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[3]);
+  }
+
+  private void unbindWriteDividedMetric(AbstractMetricService metricService) {
     Arrays.asList(STORAGE_ENGINE_WRITE_MEMTABLE, STORAGE_ENGINE_WRITE_TIME_PARTITION_INFO)
         .forEach(
             name ->
                 metricService.remove(
-                    MetricType.GAUGE,
+                    MetricType.AUTO_GAUGE,
                     Metric.MEMORY_THRESHOLD_SIZE.toString(),
                     Tag.NAME.toString(),
                     name,
@@ -182,21 +198,114 @@ public class StorageEngineMemoryMetrics implements IMetricSet {
                     GlobalMemoryMetrics.ON_HEAP,
                     Tag.LEVEL.toString(),
                     GlobalMemoryMetrics.LEVELS[3]));
+  }
+
+  // endregion
+
+  // region Memtable Divided Memory Metrics
+
+  private void bindMemtableDividedMetrics(AbstractMetricService metricService) {
+    // DevicePathCache related metrics
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getDevicePathCacheMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_WRITE_MEMTABLE_DEVICE_PATH_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[4]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getDevicePathCacheMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_WRITE_MEMTABLE_DEVICE_PATH_CACHE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[4]);
+    // BufferedArrays related metrics
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getBufferedArraysMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_WRITE_MEMTABLE_BUFFERED_ARRAYS,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[4]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getBufferedArraysMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_WRITE_MEMTABLE_BUFFERED_ARRAYS,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[4]);
+    // WalBufferQueue related metrics
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getWalBufferQueueMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_WRITE_MEMTABLE_WAL_BUFFER_QUEUE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[4]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getWalBufferQueueMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STORAGE_ENGINE_WRITE_MEMTABLE_WAL_BUFFER_QUEUE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[4]);
+  }
+
+  private void unbindMemtableDividedMetrics(AbstractMetricService metricService) {
     Arrays.asList(
-            STORAGE_ENGINE_WRITE_MEMTABLE_CACHE, STORAGE_ENGINE_WRITE_MEMTABLE_BUFFERED_ARRAYS)
+            STORAGE_ENGINE_WRITE_MEMTABLE_DEVICE_PATH_CACHE,
+            STORAGE_ENGINE_WRITE_MEMTABLE_BUFFERED_ARRAYS,
+            STORAGE_ENGINE_WRITE_MEMTABLE_WAL_BUFFER_QUEUE)
         .forEach(
-            name ->
-                metricService.remove(
-                    MetricType.GAUGE,
-                    Metric.MEMORY_THRESHOLD_SIZE.toString(),
-                    Tag.NAME.toString(),
-                    name,
-                    Tag.TYPE.toString(),
-                    GlobalMemoryMetrics.ON_HEAP,
-                    Tag.LEVEL.toString(),
-                    GlobalMemoryMetrics.LEVELS[4]));
+            name -> {
+              metricService.remove(
+                  MetricType.AUTO_GAUGE,
+                  Metric.MEMORY_THRESHOLD_SIZE.toString(),
+                  Tag.NAME.toString(),
+                  name,
+                  Tag.TYPE.toString(),
+                  GlobalMemoryMetrics.ON_HEAP,
+                  Tag.LEVEL.toString(),
+                  GlobalMemoryMetrics.LEVELS[4]);
+              metricService.remove(
+                  MetricType.AUTO_GAUGE,
+                  Metric.MEMORY_ACTUAL_SIZE.toString(),
+                  Tag.NAME.toString(),
+                  name,
+                  Tag.TYPE.toString(),
+                  GlobalMemoryMetrics.ON_HEAP,
+                  Tag.LEVEL.toString(),
+                  GlobalMemoryMetrics.LEVELS[4]);
+            });
   }
 
+  // endregion
+
   public static StorageEngineMemoryMetrics getInstance() {
     return StorageEngineMemoryMetricsHolder.INSTANCE;
   }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/StreamEngineMemoryMetrics.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/StreamEngineMemoryMetrics.java
index 2fd8da49cf4..93afd8f78a8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/StreamEngineMemoryMetrics.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/StreamEngineMemoryMetrics.java
@@ -19,9 +19,10 @@
 
 package org.apache.iotdb.db.service.metrics.memory;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.commons.service.metric.enums.Metric;
 import org.apache.iotdb.commons.service.metric.enums.Tag;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.metrics.AbstractMetricService;
 import org.apache.iotdb.metrics.metricsets.IMetricSet;
@@ -29,28 +30,40 @@ import org.apache.iotdb.metrics.utils.MetricLevel;
 import org.apache.iotdb.metrics.utils.MetricType;
 
 public class StreamEngineMemoryMetrics implements IMetricSet {
-  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private static final String STREAM_ENGINE = "StreamEngine";
 
   @Override
   public void bindTo(AbstractMetricService metricService) {
-    metricService
-        .getOrCreateGauge(
-            Metric.MEMORY_THRESHOLD_SIZE.toString(),
-            MetricLevel.NORMAL,
-            Tag.NAME.toString(),
-            STREAM_ENGINE,
-            Tag.TYPE.toString(),
-            GlobalMemoryMetrics.ON_HEAP,
-            Tag.LEVEL.toString(),
-            GlobalMemoryMetrics.LEVELS[1])
-        .set(config.getAllocateMemoryForPipe());
+    metricService.createAutoGauge(
+        Metric.MEMORY_THRESHOLD_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getPipeMemoryManager(),
+        MemoryManager::getTotalMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STREAM_ENGINE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
+    metricService.createAutoGauge(
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        MetricLevel.IMPORTANT,
+        memoryConfig.getPipeMemoryManager(),
+        MemoryManager::getUsedMemorySizeInBytes,
+        Tag.NAME.toString(),
+        STREAM_ENGINE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
   }
 
   @Override
   public void unbindFrom(AbstractMetricService metricService) {
     metricService.remove(
-        MetricType.GAUGE,
+        MetricType.AUTO_GAUGE,
         Metric.MEMORY_THRESHOLD_SIZE.toString(),
         Tag.NAME.toString(),
         STREAM_ENGINE,
@@ -58,6 +71,15 @@ public class StreamEngineMemoryMetrics implements IMetricSet {
         GlobalMemoryMetrics.ON_HEAP,
         Tag.LEVEL.toString(),
         GlobalMemoryMetrics.LEVELS[1]);
+    metricService.remove(
+        MetricType.AUTO_GAUGE,
+        Metric.MEMORY_ACTUAL_SIZE.toString(),
+        Tag.NAME.toString(),
+        STREAM_ENGINE,
+        Tag.TYPE.toString(),
+        GlobalMemoryMetrics.ON_HEAP,
+        Tag.LEVEL.toString(),
+        GlobalMemoryMetrics.LEVELS[1]);
   }
 
   public static StreamEngineMemoryMetrics getInstance() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/BloomFilterCache.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/BloomFilterCache.java
index e6407c6606c..7a41352098b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/BloomFilterCache.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/BloomFilterCache.java
@@ -20,8 +20,10 @@
 package org.apache.iotdb.db.storageengine.buffer;
 
 import org.apache.iotdb.commons.exception.IoTDBIORuntimeException;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.utils.TestOnly;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.storageengine.dataregion.read.control.FileReaderManager;
 import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileID;
@@ -47,21 +49,30 @@ public class BloomFilterCache {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(BloomFilterCache.class);
   private static final Logger DEBUG_LOGGER = LoggerFactory.getLogger("QUERY_DEBUG");
-  private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
-  private static final long MEMORY_THRESHOLD_IN_BLOOM_FILTER_CACHE =
-      CONFIG.getAllocateMemoryForBloomFilterCache();
-  private static final boolean CACHE_ENABLE = CONFIG.isMetaDataCacheEnable();
+  private static final DataNodeMemoryConfig MEMORY_CONFIG =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
+  private static final IMemoryBlock CACHE_MEMORY_BLOCK;
+  private static final boolean CACHE_ENABLE = MEMORY_CONFIG.isMetaDataCacheEnable();
   private final AtomicLong entryAverageSize = new AtomicLong(0);
 
   private final Cache<BloomFilterCacheKey, BloomFilter> lruCache;
 
+  static {
+    CACHE_MEMORY_BLOCK =
+        MEMORY_CONFIG
+            .getBloomFilterCacheMemoryManager()
+            .exactAllocate("BloomFilterCache", MemoryBlockType.STATIC);
+    // TODO @spricoder: find a way to get the size of the BloomFilterCache
+    CACHE_MEMORY_BLOCK.allocate(CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes());
+  }
+
   private BloomFilterCache() {
     if (CACHE_ENABLE) {
-      LOGGER.info("BloomFilterCache size = {}", MEMORY_THRESHOLD_IN_BLOOM_FILTER_CACHE);
+      LOGGER.info("BloomFilterCache size = {}", CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes());
     }
     lruCache =
         Caffeine.newBuilder()
-            .maximumWeight(MEMORY_THRESHOLD_IN_BLOOM_FILTER_CACHE)
+            .maximumWeight(CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes())
             .weigher(
                 (Weigher<BloomFilterCacheKey, BloomFilter>)
                     (key, bloomFilter) ->
@@ -120,7 +131,7 @@ public class BloomFilterCache {
   }
 
   public long getMaxMemory() {
-    return MEMORY_THRESHOLD_IN_BLOOM_FILTER_CACHE;
+    return CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes();
   }
 
   public double getAverageLoadPenalty() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/ChunkCache.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/ChunkCache.java
index 4044b5db87c..1c39b993a3c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/ChunkCache.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/ChunkCache.java
@@ -20,9 +20,11 @@
 package org.apache.iotdb.db.storageengine.buffer;
 
 import org.apache.iotdb.commons.exception.IoTDBIORuntimeException;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.service.metric.MetricService;
 import org.apache.iotdb.commons.utils.TestOnly;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.queryengine.execution.fragment.QueryContext;
 import org.apache.iotdb.db.queryengine.metric.ChunkCacheMetrics;
@@ -59,10 +61,10 @@ public class ChunkCache {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(ChunkCache.class);
   private static final Logger DEBUG_LOGGER = LoggerFactory.getLogger("QUERY_DEBUG");
-  private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
-  private static final long MEMORY_THRESHOLD_IN_CHUNK_CACHE =
-      CONFIG.getAllocateMemoryForChunkCache();
-  private static final boolean CACHE_ENABLE = CONFIG.isMetaDataCacheEnable();
+  private static final DataNodeMemoryConfig MEMORY_CONFIG =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
+  private static final IMemoryBlock CACHE_MEMORY_BLOCK;
+  private static final boolean CACHE_ENABLE = MEMORY_CONFIG.isMetaDataCacheEnable();
 
   private static final SeriesScanCostMetricSet SERIES_SCAN_COST_METRIC_SET =
       SeriesScanCostMetricSet.getInstance();
@@ -70,13 +72,22 @@ public class ChunkCache {
   // to save memory footprint, we don't save measurementId in ChunkHeader of Chunk
   private final Cache<ChunkCacheKey, Chunk> lruCache;
 
+  static {
+    CACHE_MEMORY_BLOCK =
+        MEMORY_CONFIG
+            .getChunkCacheMemoryManager()
+            .exactAllocate("ChunkCache", MemoryBlockType.STATIC);
+    // TODO @spricoder: find a way to get the size of the ChunkCache
+    CACHE_MEMORY_BLOCK.allocate(CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes());
+  }
+
   private ChunkCache() {
     if (CACHE_ENABLE) {
-      LOGGER.info("ChunkCache size = {}", MEMORY_THRESHOLD_IN_CHUNK_CACHE);
+      LOGGER.info("ChunkCache size = {}", CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes());
     }
     lruCache =
         Caffeine.newBuilder()
-            .maximumWeight(MEMORY_THRESHOLD_IN_CHUNK_CACHE)
+            .maximumWeight(CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes())
             .weigher(
                 (Weigher<ChunkCacheKey, Chunk>)
                     (key, chunk) ->
@@ -191,7 +202,7 @@ public class ChunkCache {
   }
 
   public long getMaxMemory() {
-    return MEMORY_THRESHOLD_IN_CHUNK_CACHE;
+    return CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes();
   }
 
   public double getAverageLoadPenalty() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/TimeSeriesMetadataCache.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/TimeSeriesMetadataCache.java
index f5262ea07aa..9b4bb17f63c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/TimeSeriesMetadataCache.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/TimeSeriesMetadataCache.java
@@ -20,9 +20,11 @@
 package org.apache.iotdb.db.storageengine.buffer;
 
 import org.apache.iotdb.commons.conf.IoTDBConstant;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.service.metric.MetricService;
 import org.apache.iotdb.commons.utils.TestOnly;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.queryengine.execution.fragment.QueryContext;
 import org.apache.iotdb.db.queryengine.metric.SeriesScanCostMetricSet;
@@ -66,10 +68,10 @@ public class TimeSeriesMetadataCache {
 
   private static final Logger logger = LoggerFactory.getLogger(TimeSeriesMetadataCache.class);
   private static final Logger DEBUG_LOGGER = LoggerFactory.getLogger("QUERY_DEBUG");
-  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-  private static final long MEMORY_THRESHOLD_IN_TIME_SERIES_METADATA_CACHE =
-      config.getAllocateMemoryForTimeSeriesMetaDataCache();
-  private static final boolean CACHE_ENABLE = config.isMetaDataCacheEnable();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
+  private static final IMemoryBlock CACHE_MEMORY_BLOCK;
+  private static final boolean CACHE_ENABLE = memoryConfig.isMetaDataCacheEnable();
 
   private static final SeriesScanCostMetricSet SERIES_SCAN_COST_METRIC_SET =
       SeriesScanCostMetricSet.getInstance();
@@ -82,14 +84,23 @@ public class TimeSeriesMetadataCache {
       Collections.synchronizedMap(new WeakHashMap<>());
   private static final String SEPARATOR = "$";
 
+  static {
+    CACHE_MEMORY_BLOCK =
+        memoryConfig
+            .getTimeSeriesMetaDataCacheMemoryManager()
+            .exactAllocate("TimeSeriesMetadataCache", MemoryBlockType.STATIC);
+    // TODO @spricoder find a better way to get the size of cache
+    CACHE_MEMORY_BLOCK.allocate(CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes());
+  }
+
   private TimeSeriesMetadataCache() {
     if (CACHE_ENABLE) {
       logger.info(
-          "TimeSeriesMetadataCache size = {}", MEMORY_THRESHOLD_IN_TIME_SERIES_METADATA_CACHE);
+          "TimeSeriesMetadataCache size = {}", CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes());
     }
     lruCache =
         Caffeine.newBuilder()
-            .maximumWeight(MEMORY_THRESHOLD_IN_TIME_SERIES_METADATA_CACHE)
+            .maximumWeight(CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes())
             .weigher(
                 (Weigher<TimeSeriesMetadataCacheKey, TimeseriesMetadata>)
                     (key, value) ->
@@ -257,7 +268,7 @@ public class TimeSeriesMetadataCache {
   }
 
   public long getMaxMemory() {
-    return MEMORY_THRESHOLD_IN_TIME_SERIES_METADATA_CACHE;
+    return CACHE_MEMORY_BLOCK.getTotalMemorySizeInBytes();
   }
 
   public double getAverageLoadPenalty() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegionInfo.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegionInfo.java
index fa0e4227c68..0e8e4902c8b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegionInfo.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegionInfo.java
@@ -42,8 +42,10 @@ public class DataRegionInfo {
   private final long storageGroupSizeReportThreshold =
       (long)
           (IoTDBDescriptor.getInstance().getConfig().getWriteMemoryVariationReportProportion()
-              * IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForStorageEngine()
-              * IoTDBDescriptor.getInstance().getConfig().getWriteProportionForMemtable());
+              * IoTDBDescriptor.getInstance()
+                  .getMemoryConfig()
+                  .getMemtableMemoryManager()
+                  .getTotalMemorySizeInBytes());
 
   private final AtomicLong lastReportedSize = new AtomicLong();
 
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/MemoryControlledWALEntryQueue.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/MemoryControlledWALEntryQueue.java
index ddb1310564b..961d1dd97c3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/MemoryControlledWALEntryQueue.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/MemoryControlledWALEntryQueue.java
@@ -27,7 +27,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
 public class MemoryControlledWALEntryQueue {
-
   private final BlockingQueue<WALEntry> queue;
   private static final Object nonFullCondition = new Object();
 
@@ -38,7 +37,7 @@ public class MemoryControlledWALEntryQueue {
   public WALEntry poll(long timeout, TimeUnit unit) throws InterruptedException {
     WALEntry e = queue.poll(timeout, unit);
     if (e != null) {
-      SystemInfo.getInstance().updateWalQueueMemoryCost(-getElementSize(e));
+      SystemInfo.getInstance().getWalBufferQueueMemoryBlock().release(getElementSize(e));
       synchronized (nonFullCondition) {
         nonFullCondition.notifyAll();
       }
@@ -49,21 +48,19 @@ public class MemoryControlledWALEntryQueue {
   public void put(WALEntry e) throws InterruptedException {
     long elementSize = getElementSize(e);
     synchronized (nonFullCondition) {
-      while (SystemInfo.getInstance().cannotReserveMemoryForWalEntry(elementSize)) {
+      while (!SystemInfo.getInstance().getWalBufferQueueMemoryBlock().allocate(elementSize)) {
         nonFullCondition.wait();
       }
     }
     queue.put(e);
-    SystemInfo.getInstance().updateWalQueueMemoryCost(elementSize);
   }
 
   public WALEntry take() throws InterruptedException {
     WALEntry e = queue.take();
-    SystemInfo.getInstance().updateWalQueueMemoryCost(-getElementSize(e));
+    SystemInfo.getInstance().getWalBufferQueueMemoryBlock().release(getElementSize(e));
     synchronized (nonFullCondition) {
       nonFullCondition.notifyAll();
     }
-
     return e;
   }
 
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALInsertNodeCache.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALInsertNodeCache.java
index 76857c04983..2c03a605caf 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALInsertNodeCache.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALInsertNodeCache.java
@@ -20,6 +20,7 @@
 package org.apache.iotdb.db.storageengine.dataregion.wal.utils;
 
 import org.apache.iotdb.commons.utils.TestOnly;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.pipe.metric.overview.PipeWALInsertNodeCacheMetrics;
@@ -58,6 +59,8 @@ public class WALInsertNodeCache {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(WALInsertNodeCache.class);
   private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig MEMORY_CONFIG =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
 
   private final PipeMemoryBlock allocatedMemoryBlock;
   // Used to adjust the memory usage of the cache
@@ -76,7 +79,7 @@ public class WALInsertNodeCache {
         (long)
             Math.min(
                 (double) 2 * CONFIG.getWalFileSizeThresholdInByte(),
-                CONFIG.getAllocateMemoryForPipe() * 0.8 / 5);
+                MEMORY_CONFIG.getPipeMemoryManager().getTotalMemorySizeInBytes() * 0.8 / 5);
     allocatedMemoryBlock =
         PipeDataNodeResourceManager.memory()
             .tryAllocate(requestedAllocateSize)
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileAnalyzeSchemaMemoryBlock.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileAnalyzeSchemaMemoryBlock.java
index e5d9859b25d..2bf276748cc 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileAnalyzeSchemaMemoryBlock.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileAnalyzeSchemaMemoryBlock.java
@@ -111,7 +111,7 @@ public class LoadTsFileAnalyzeSchemaMemoryBlock extends LoadTsFileAbstractMemory
     return "LoadTsFileAnalyzeSchemaMemoryBlock{"
         + "totalMemorySizeInBytes="
         + totalMemorySizeInBytes
-        + ", memoryUsageInBytes="
+        + ", usedMemoryInBytes="
         + memoryUsageInBytes.get()
         + '}';
   }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileDataCacheMemoryBlock.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileDataCacheMemoryBlock.java
index c581ae768f4..4611df37aa8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileDataCacheMemoryBlock.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileDataCacheMemoryBlock.java
@@ -74,7 +74,7 @@ public class LoadTsFileDataCacheMemoryBlock extends LoadTsFileAbstractMemoryBloc
   @Override
   public synchronized void forceResize(long newSizeInBytes) {
     throw new UnsupportedOperationException(
-        "resize is not supported for LoadTsFileDataCacheMemoryBlock");
+        "setTotalMemorySizeInBytes is not supported for LoadTsFileDataCacheMemoryBlock");
   }
 
   @Override
@@ -128,7 +128,7 @@ public class LoadTsFileDataCacheMemoryBlock extends LoadTsFileAbstractMemoryBloc
     return "LoadTsFileDataCacheMemoryBlock{"
         + "limitedMemorySizeInBytes="
         + limitedMemorySizeInBytes.get()
-        + ", memoryUsageInBytes="
+        + ", usedMemoryInBytes="
         + memoryUsageInBytes.get()
         + '}';
   }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileMemoryManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileMemoryManager.java
index 7a5fc392d62..095c24a8cc7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileMemoryManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileMemoryManager.java
@@ -117,7 +117,7 @@ public class LoadTsFileMemoryManager {
 
       if (memoryBlock.getMemoryUsageInBytes() > newSizeInBytes) {
         LOGGER.error(
-            "Load: Failed to resize memory block {} to {} bytes, current memory usage {} bytes",
+            "Load: Failed to setTotalMemorySizeInBytes memory block {} to {} bytes, current memory usage {} bytes",
             memoryBlock,
             newSizeInBytes,
             memoryBlock.getMemoryUsageInBytes());
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/PrimitiveArrayManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/PrimitiveArrayManager.java
index f3363ef7627..f4bc88db2ef 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/PrimitiveArrayManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/PrimitiveArrayManager.java
@@ -18,6 +18,9 @@
  */
 package org.apache.iotdb.db.storageengine.rescon.memory;
 
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.utils.datastructure.TVListSortAlgorithm;
@@ -39,6 +42,9 @@ public class PrimitiveArrayManager {
 
   private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
 
+  private static final DataNodeMemoryConfig MEMORY_CONFIG =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
+
   public static final int ARRAY_SIZE = CONFIG.getPrimitiveArraySize();
 
   public static final TVListSortAlgorithm TVLIST_SORT_ALGORITHM = CONFIG.getTvListSortAlgorithm();
@@ -49,11 +55,15 @@ public class PrimitiveArrayManager {
    */
   private static final double AMPLIFICATION_FACTOR = 1.5;
 
+  /** memory block for all arrays */
+  private static final IMemoryBlock POOLED_ARRAYS_MEMORY_BLOCK =
+      MEMORY_CONFIG
+          .getBufferedArraysMemoryManager()
+          .exactAllocate("BufferedArrays", MemoryBlockType.DYNAMIC);
+
   /** threshold total size of arrays for all data types */
   private static final double POOLED_ARRAYS_MEMORY_THRESHOLD =
-      CONFIG.getAllocateMemoryForStorageEngine()
-          * CONFIG.getBufferedArraysMemoryProportion()
-          / AMPLIFICATION_FACTOR;
+      POOLED_ARRAYS_MEMORY_BLOCK.getTotalMemorySizeInBytes() / AMPLIFICATION_FACTOR;
 
   /** TSDataType#serialize() -> ArrayDeque<Array>, VECTOR and UNKNOWN are ignored */
   private static final ArrayDeque[] POOLED_ARRAYS = new ArrayDeque[TSDataType.values().length];
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/SystemInfo.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/SystemInfo.java
index 56e2ef4dae6..c3fc04cb177 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/SystemInfo.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/SystemInfo.java
@@ -21,7 +21,10 @@ package org.apache.iotdb.db.storageengine.rescon.memory;
 
 import org.apache.iotdb.commons.concurrent.IoTDBThreadPoolFactory;
 import org.apache.iotdb.commons.concurrent.ThreadName;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.utils.TestOnly;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.exception.WriteProcessRejectException;
@@ -40,27 +43,26 @@ import java.util.Map;
 import java.util.PriorityQueue;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
 public class SystemInfo {
+  private static final Logger logger = LoggerFactory.getLogger(SystemInfo.class);
 
   private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-  private static final Logger logger = LoggerFactory.getLogger(SystemInfo.class);
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
 
   private long totalStorageGroupMemCost = 0L;
   private volatile boolean rejected = false;
 
   private long memorySizeForMemtable;
-  private long memorySizeForCompaction;
-  private long memorySizeForWalBufferQueue;
-  private long totalDirectBufferMemorySizeLimit;
   private final Map<DataRegionInfo, Long> reportedStorageGroupMemCostMap = new HashMap<>();
 
   private long flushingMemTablesCost = 0L;
-  private final AtomicLong directBufferMemoryCost = new AtomicLong(0);
-  private final AtomicLong compactionMemoryCost = new AtomicLong(0L);
+  private IMemoryBlock walBufferQueueMemoryBlock;
+  private IMemoryBlock directBufferMemoryBlock;
+  private IMemoryBlock compactionMemoryBlock;
   private final AtomicLong seqInnerSpaceCompactionMemoryCost = new AtomicLong(0L);
   private final AtomicLong unseqInnerSpaceCompactionMemoryCost = new AtomicLong(0L);
   private final AtomicLong crossSpaceCompactionMemoryCost = new AtomicLong(0L);
@@ -73,14 +75,24 @@ public class SystemInfo {
   private final ExecutorService flushTaskSubmitThreadPool =
       IoTDBThreadPoolFactory.newSingleThreadExecutor(ThreadName.FLUSH_TASK_SUBMIT.getName());
   private double FLUSH_THRESHOLD = memorySizeForMemtable * config.getFlushProportion();
-  private double REJECT_THRESHOLD = memorySizeForMemtable * config.getRejectProportion();
+  private double REJECT_THRESHOLD = memorySizeForMemtable * memoryConfig.getRejectProportion();
 
   private volatile boolean isEncodingFasterThanIo = true;
 
-  private final AtomicLong walBufferQueueMemoryCost = new AtomicLong(0);
-
   private SystemInfo() {
-    allocateWriteMemory();
+    compactionMemoryBlock =
+        memoryConfig
+            .getCompactionMemoryManager()
+            .exactAllocate("Compaction", MemoryBlockType.DYNAMIC);
+    walBufferQueueMemoryBlock =
+        memoryConfig
+            .getWalBufferQueueMemoryManager()
+            .exactAllocate("WalBufferQueue", MemoryBlockType.DYNAMIC);
+    directBufferMemoryBlock =
+        memoryConfig
+            .getDirectBufferMemoryManager()
+            .exactAllocate("DirectBuffer", MemoryBlockType.DYNAMIC);
+    loadWriteMemory();
   }
 
   /**
@@ -200,28 +212,19 @@ public class SystemInfo {
   }
 
   public boolean addDirectBufferMemoryCost(long size) {
-    AtomicBoolean result = new AtomicBoolean(false);
-    directBufferMemoryCost.updateAndGet(
-        memCost -> {
-          if (memCost + size > totalDirectBufferMemorySizeLimit) {
-            return memCost;
-          }
-          result.set(true);
-          return memCost + size;
-        });
-    return result.get();
+    return directBufferMemoryBlock.allocate(size);
   }
 
   public void decreaseDirectBufferMemoryCost(long size) {
-    directBufferMemoryCost.addAndGet(-size);
+    directBufferMemoryBlock.release(size);
   }
 
   public long getTotalDirectBufferMemorySizeLimit() {
-    return totalDirectBufferMemorySizeLimit;
+    return memoryConfig.getDirectBufferMemoryManager().getTotalMemorySizeInBytes();
   }
 
   public long getDirectBufferMemoryCost() {
-    return directBufferMemoryCost.get();
+    return directBufferMemoryBlock.getUsedMemoryInBytes();
   }
 
   public boolean addCompactionFileNum(int fileNum, long timeOutInSecond)
@@ -276,75 +279,29 @@ public class SystemInfo {
     }
   }
 
-  public boolean addCompactionMemoryCost(
-      CompactionTaskType taskType, long memoryCost, long timeOutInSecond)
-      throws InterruptedException, CompactionMemoryNotEnoughException {
-    if (memoryCost > memorySizeForCompaction) {
-      // required memory cost is greater than the total memory budget for compaction
-      throw new CompactionMemoryNotEnoughException(
-          String.format(
-              "Required memory cost %d bytes is greater than "
-                  + "the total memory budget for compaction %d bytes",
-              memoryCost, memorySizeForCompaction));
-    }
-    long startTime = System.currentTimeMillis();
-    long originSize = this.compactionMemoryCost.get();
-    while (originSize + memoryCost > memorySizeForCompaction
-        || !compactionMemoryCost.compareAndSet(originSize, originSize + memoryCost)) {
-      if (System.currentTimeMillis() - startTime >= timeOutInSecond * 1000L) {
-        throw new CompactionMemoryNotEnoughException(
-            String.format(
-                "Failed to allocate %d bytes memory for compaction after %d seconds, "
-                    + "total memory budget for compaction module is %d bytes, %d bytes is used",
-                memoryCost, timeOutInSecond, memorySizeForCompaction, originSize));
-      }
-      Thread.sleep(100);
-      originSize = this.compactionMemoryCost.get();
-    }
-    switch (taskType) {
-      case INNER_SEQ:
-        seqInnerSpaceCompactionMemoryCost.addAndGet(memoryCost);
-        break;
-      case INNER_UNSEQ:
-        unseqInnerSpaceCompactionMemoryCost.addAndGet(memoryCost);
-        break;
-      case CROSS:
-        crossSpaceCompactionMemoryCost.addAndGet(memoryCost);
-        break;
-      case SETTLE:
-        settleCompactionMemoryCost.addAndGet(memoryCost);
-        break;
-      default:
-    }
-    return true;
-  }
-
   public void addCompactionMemoryCost(
       CompactionTaskType taskType, long memoryCost, boolean waitUntilAcquired)
       throws CompactionMemoryNotEnoughException, InterruptedException {
-    if (memoryCost > memorySizeForCompaction) {
+    if (memoryCost > compactionMemoryBlock.getTotalMemorySizeInBytes()) {
       // required memory cost is greater than the total memory budget for compaction
       throw new CompactionMemoryNotEnoughException(
           String.format(
               "Required memory cost %d bytes is greater than "
                   + "the total memory budget for compaction %d bytes",
-              memoryCost, memorySizeForCompaction));
+              memoryCost, compactionMemoryBlock.getTotalMemorySizeInBytes()));
     }
-    long originSize = this.compactionMemoryCost.get();
-    while (true) {
-      boolean canUpdate = originSize + memoryCost <= memorySizeForCompaction;
-      if (!canUpdate && !waitUntilAcquired) {
-        throw new CompactionMemoryNotEnoughException(
-            String.format(
-                "Failed to allocate %d bytes memory for compaction, "
-                    + "total memory budget for compaction module is %d bytes, %d bytes is used",
-                memoryCost, memorySizeForCompaction, originSize));
-      }
-      if (canUpdate && compactionMemoryCost.compareAndSet(originSize, originSize + memoryCost)) {
-        break;
-      }
-      Thread.sleep(TimeUnit.MILLISECONDS.toMillis(100));
-      originSize = this.compactionMemoryCost.get();
+    boolean allocateResult =
+        waitUntilAcquired
+            ? compactionMemoryBlock.allocateUntilAvailable(memoryCost, 100)
+            : compactionMemoryBlock.allocate(memoryCost);
+    if (!allocateResult) {
+      throw new CompactionMemoryNotEnoughException(
+          String.format(
+              "Failed to allocate %d bytes memory for compaction, "
+                  + "total memory budget for compaction module is %d bytes, %d bytes is used",
+              memoryCost,
+              compactionMemoryBlock.getTotalMemorySizeInBytes(),
+              compactionMemoryBlock.getUsedMemoryInBytes()));
     }
     switch (taskType) {
       case INNER_SEQ:
@@ -365,7 +322,7 @@ public class SystemInfo {
 
   public synchronized void resetCompactionMemoryCost(
       CompactionTaskType taskType, long compactionMemoryCost) {
-    this.compactionMemoryCost.addAndGet(-compactionMemoryCost);
+    this.compactionMemoryBlock.release(compactionMemoryCost);
     switch (taskType) {
       case INNER_SEQ:
         seqInnerSpaceCompactionMemoryCost.addAndGet(-compactionMemoryCost);
@@ -389,38 +346,22 @@ public class SystemInfo {
   }
 
   public long getMemorySizeForCompaction() {
-    return memorySizeForCompaction;
-  }
-
-  public void allocateWriteMemory() {
-    // when we can't get the OffHeapMemory variable from environment, it will be 0
-    // and the limit should not be effective
-    totalDirectBufferMemorySizeLimit =
-        config.getMaxOffHeapMemoryBytes() == 0
-            ? Long.MAX_VALUE
-            : (long)
-                (config.getMaxOffHeapMemoryBytes()
-                    * config.getMaxDirectBufferOffHeapMemorySizeProportion());
-    memorySizeForMemtable =
-        (long)
-            (config.getAllocateMemoryForStorageEngine() * config.getWriteProportionForMemtable());
-    memorySizeForCompaction =
-        (long) (config.getAllocateMemoryForStorageEngine() * config.getCompactionProportion());
-    memorySizeForWalBufferQueue =
-        (long)
-            (config.getAllocateMemoryForStorageEngine()
-                * config.getWriteProportionForMemtable()
-                * config.getWalBufferQueueProportion());
+    return compactionMemoryBlock.getTotalMemorySizeInBytes();
+  }
+
+  public void loadWriteMemory() {
+    memorySizeForMemtable = memoryConfig.getMemtableMemoryManager().getTotalMemorySizeInBytes();
     FLUSH_THRESHOLD = memorySizeForMemtable * config.getFlushProportion();
-    REJECT_THRESHOLD = memorySizeForMemtable * config.getRejectProportion();
+    REJECT_THRESHOLD = memorySizeForMemtable * memoryConfig.getRejectProportion();
     WritingMetrics.getInstance().recordFlushThreshold(FLUSH_THRESHOLD);
     WritingMetrics.getInstance().recordRejectThreshold(REJECT_THRESHOLD);
-    WritingMetrics.getInstance().recordWALQueueMaxMemorySize(memorySizeForWalBufferQueue);
+    WritingMetrics.getInstance()
+        .recordWALQueueMaxMemorySize(walBufferQueueMemoryBlock.getTotalMemorySizeInBytes());
   }
 
   @TestOnly
   public void setMemorySizeForCompaction(long size) {
-    memorySizeForCompaction = size;
+    compactionMemoryBlock.setTotalMemorySizeInBytes(size);
   }
 
   @TestOnly
@@ -432,8 +373,8 @@ public class SystemInfo {
     return totalFileLimitForCompactionTask;
   }
 
-  public AtomicLong getCompactionMemoryCost() {
-    return compactionMemoryCost;
+  public IMemoryBlock getCompactionMemoryBlock() {
+    return compactionMemoryBlock;
   }
 
   public AtomicLong getSeqInnerSpaceCompactionMemoryCost() {
@@ -529,19 +470,21 @@ public class SystemInfo {
   public synchronized void applyTemporaryMemoryForFlushing(long estimatedTemporaryMemSize) {
     memorySizeForMemtable -= estimatedTemporaryMemSize;
     FLUSH_THRESHOLD = memorySizeForMemtable * config.getFlushProportion();
-    REJECT_THRESHOLD = memorySizeForMemtable * config.getRejectProportion();
+    REJECT_THRESHOLD = memorySizeForMemtable * memoryConfig.getRejectProportion();
     WritingMetrics.getInstance().recordFlushThreshold(FLUSH_THRESHOLD);
     WritingMetrics.getInstance().recordRejectThreshold(REJECT_THRESHOLD);
-    WritingMetrics.getInstance().recordWALQueueMaxMemorySize(memorySizeForWalBufferQueue);
+    WritingMetrics.getInstance()
+        .recordWALQueueMaxMemorySize(walBufferQueueMemoryBlock.getTotalMemorySizeInBytes());
   }
 
   public synchronized void releaseTemporaryMemoryForFlushing(long estimatedTemporaryMemSize) {
     memorySizeForMemtable += estimatedTemporaryMemSize;
     FLUSH_THRESHOLD = memorySizeForMemtable * config.getFlushProportion();
-    REJECT_THRESHOLD = memorySizeForMemtable * config.getRejectProportion();
+    REJECT_THRESHOLD = memorySizeForMemtable * memoryConfig.getRejectProportion();
     WritingMetrics.getInstance().recordFlushThreshold(FLUSH_THRESHOLD);
     WritingMetrics.getInstance().recordRejectThreshold(REJECT_THRESHOLD);
-    WritingMetrics.getInstance().recordWALQueueMaxMemorySize(memorySizeForWalBufferQueue);
+    WritingMetrics.getInstance()
+        .recordWALQueueMaxMemorySize(walBufferQueueMemoryBlock.getTotalMemorySizeInBytes());
   }
 
   public long getTotalMemTableSize() {
@@ -556,15 +499,7 @@ public class SystemInfo {
     return REJECT_THRESHOLD;
   }
 
-  public long getCurrentWalQueueMemoryCost() {
-    return walBufferQueueMemoryCost.get();
-  }
-
-  public void updateWalQueueMemoryCost(long delta) {
-    walBufferQueueMemoryCost.addAndGet(delta);
-  }
-
-  public boolean cannotReserveMemoryForWalEntry(long walEntrySize) {
-    return walBufferQueueMemoryCost.get() + walEntrySize > memorySizeForWalBufferQueue;
+  public IMemoryBlock getWalBufferQueueMemoryBlock() {
+    return walBufferQueueMemoryBlock;
   }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/TimePartitionManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/TimePartitionManager.java
index 0d545af0c98..30771e3db78 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/TimePartitionManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/TimePartitionManager.java
@@ -20,6 +20,8 @@
 package org.apache.iotdb.db.storageengine.rescon.memory;
 
 import org.apache.iotdb.commons.consensus.DataRegionId;
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.utils.TestOnly;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.pipe.extractor.dataregion.realtime.listener.PipeTimePartitionListener;
@@ -41,12 +43,15 @@ public class TimePartitionManager {
   private static final Logger logger = LoggerFactory.getLogger(TimePartitionManager.class);
   final Map<DataRegionId, Map<Long, TimePartitionInfo>> timePartitionInfoMap;
 
-  long memCost = 0;
-  long timePartitionInfoMemoryThreshold =
-      IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForTimePartitionInfo();
+  IMemoryBlock timePartitionInfoMemoryBlock;
 
   private TimePartitionManager() {
     timePartitionInfoMap = new HashMap<>();
+    timePartitionInfoMemoryBlock =
+        IoTDBDescriptor.getInstance()
+            .getMemoryConfig()
+            .getTimePartitionInfoMemoryManager()
+            .exactAllocate("TimePartitionInfoMemoryBlock", MemoryBlockType.DYNAMIC);
   }
 
   public void registerTimePartitionInfo(TimePartitionInfo timePartitionInfo) {
@@ -82,10 +87,12 @@ public class TimePartitionManager {
               .get(timePartitionId);
       if (timePartitionInfo != null) {
         timePartitionInfo.lastSystemFlushTime = systemFlushTime;
-        memCost += memSize - timePartitionInfo.memSize;
+        timePartitionInfoMemoryBlock.forceAllocateWithoutLimitation(
+            memSize - timePartitionInfo.memSize);
         timePartitionInfo.memSize = memSize;
         timePartitionInfo.isActive = isActive;
-        if (memCost > timePartitionInfoMemoryThreshold) {
+        if (timePartitionInfoMemoryBlock.getUsedMemoryInBytes()
+            > timePartitionInfoMemoryBlock.getTotalMemorySizeInBytes()) {
           degradeLastFlushTime();
         }
       }
@@ -112,12 +119,13 @@ public class TimePartitionManager {
         treeSet.addAll(entry.getValue().values());
       }
 
-      while (memCost > timePartitionInfoMemoryThreshold) {
+      while (timePartitionInfoMemoryBlock.getUsedMemoryInBytes()
+          > timePartitionInfoMemoryBlock.getTotalMemorySizeInBytes()) {
         TimePartitionInfo timePartitionInfo = treeSet.pollFirst();
         if (timePartitionInfo == null) {
           return;
         }
-        memCost -= timePartitionInfo.memSize + Long.BYTES;
+        timePartitionInfoMemoryBlock.release(timePartitionInfo.memSize + Long.BYTES);
         DataRegion dataRegion =
             StorageEngine.getInstance().getDataRegion(timePartitionInfo.dataRegionId);
         if (dataRegion != null) {
@@ -127,7 +135,7 @@ public class TimePartitionManager {
               timePartitionInfo.dataRegionId,
               timePartitionInfo.partitionId,
               timePartitionInfo.memSize,
-              memCost);
+              timePartitionInfoMemoryBlock.getUsedMemoryInBytes());
         }
         timePartitionInfoMap
             .get(timePartitionInfo.dataRegionId)
@@ -143,7 +151,7 @@ public class TimePartitionManager {
       if (timePartitionInfoMapForRegion != null) {
         for (TimePartitionInfo timePartitionInfo : timePartitionInfoMapForRegion.values()) {
           if (timePartitionInfo != null) {
-            memCost -= timePartitionInfo.memSize + Long.BYTES;
+            timePartitionInfoMemoryBlock.release(timePartitionInfo.memSize + Long.BYTES);
           }
         }
       }
@@ -162,16 +170,17 @@ public class TimePartitionManager {
     }
   }
 
+  @TestOnly
   public void clear() {
     synchronized (timePartitionInfoMap) {
       timePartitionInfoMap.clear();
-      memCost = 0;
+      timePartitionInfoMemoryBlock.setUsedMemoryInBytes(0L);
     }
   }
 
   @TestOnly
   public void setTimePartitionInfoMemoryThreshold(long timePartitionInfoMemoryThreshold) {
-    this.timePartitionInfoMemoryThreshold = timePartitionInfoMemoryThreshold;
+    timePartitionInfoMemoryBlock.setTotalMemorySizeInBytes(timePartitionInfoMemoryThreshold);
   }
 
   public static TimePartitionManager getInstance() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/TsFileResourceManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/TsFileResourceManager.java
index c7eede74197..32f512b758b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/TsFileResourceManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/memory/TsFileResourceManager.java
@@ -19,8 +19,10 @@
 
 package org.apache.iotdb.db.storageengine.rescon.memory;
 
+import org.apache.iotdb.commons.memory.IMemoryBlock;
+import org.apache.iotdb.commons.memory.MemoryBlockType;
 import org.apache.iotdb.commons.utils.TestOnly;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource;
 import org.apache.iotdb.db.storageengine.dataregion.tsfile.timeindex.TimeIndexLevel;
@@ -33,24 +35,29 @@ import java.util.TreeSet;
 public class TsFileResourceManager {
   private static final Logger logger = LoggerFactory.getLogger(TsFileResourceManager.class);
 
-  private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig MEMORY_CONFIG =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
 
-  /** threshold total memory for all TimeIndex */
-  private long timeIndexMemoryThreshold = CONFIG.getAllocateMemoryForTimeIndex();
+  /** The memory block of time index */
+  private final IMemoryBlock memoryBlock;
 
   /** store the sealed TsFileResource, sorted by priority of TimeIndex */
   private final TreeSet<TsFileResource> sealedTsFileResources =
       new TreeSet<>(TsFileResource::compareIndexDegradePriority);
 
-  /** total used memory for TimeIndex */
-  private long totalTimeIndexMemCost;
-
   // degraded time index number
   private long degradedTimeIndexNum = 0;
 
+  private TsFileResourceManager() {
+    memoryBlock =
+        MEMORY_CONFIG
+            .getTimeIndexMemoryManager()
+            .exactAllocate("TimeIndex", MemoryBlockType.DYNAMIC);
+  }
+
   @TestOnly
   public void setTimeIndexMemoryThreshold(long timeIndexMemoryThreshold) {
-    this.timeIndexMemoryThreshold = timeIndexMemoryThreshold;
+    this.memoryBlock.setTotalMemorySizeInBytes(timeIndexMemoryThreshold);
   }
 
   public long getPriorityQueueSize() {
@@ -64,7 +71,7 @@ public class TsFileResourceManager {
   public synchronized void registerSealedTsFileResource(TsFileResource tsFileResource) {
     if (!sealedTsFileResources.contains(tsFileResource)) {
       sealedTsFileResources.add(tsFileResource);
-      totalTimeIndexMemCost += tsFileResource.calculateRamSize();
+      memoryBlock.forceAllocateWithoutLimitation(tsFileResource.calculateRamSize());
       chooseTsFileResourceToDegrade();
     }
   }
@@ -75,10 +82,10 @@ public class TsFileResourceManager {
       sealedTsFileResources.remove(tsFileResource);
       if (TimeIndexLevel.valueOf(tsFileResource.getTimeIndexType())
           == TimeIndexLevel.FILE_TIME_INDEX) {
-        totalTimeIndexMemCost -= tsFileResource.calculateRamSize();
+        memoryBlock.release(tsFileResource.calculateRamSize());
         degradedTimeIndexNum--;
       } else {
-        totalTimeIndexMemCost -= tsFileResource.calculateRamSize();
+        memoryBlock.release(tsFileResource.calculateRamSize());
       }
     }
   }
@@ -102,7 +109,7 @@ public class TsFileResourceManager {
 
   /** once degradation is triggered, the total memory for timeIndex should reduce */
   private void releaseTimeIndexMemCost(long memCost) {
-    totalTimeIndexMemCost -= memCost;
+    memoryBlock.release(memCost);
   }
 
   /**
@@ -110,7 +117,7 @@ public class TsFileResourceManager {
    * threshold.
    */
   private void chooseTsFileResourceToDegrade() {
-    while (totalTimeIndexMemCost > timeIndexMemoryThreshold) {
+    while (memoryBlock.getUsedMemoryInBytes() > memoryBlock.getTotalMemorySizeInBytes()) {
       TsFileResource tsFileResource = sealedTsFileResources.pollFirst();
       if (tsFileResource == null
           || TimeIndexLevel.valueOf(tsFileResource.getTimeIndexType())
@@ -133,17 +140,18 @@ public class TsFileResourceManager {
   }
 
   public long getTimeIndexMemoryThreshold() {
-    return timeIndexMemoryThreshold;
+    return memoryBlock.getTotalMemorySizeInBytes();
   }
 
   public long getTotalTimeIndexMemCost() {
-    return totalTimeIndexMemCost;
+    return memoryBlock.getUsedMemoryInBytes();
   }
 
   /** function for clearing TsFileManager */
+  @TestOnly
   public synchronized void clear() {
     this.sealedTsFileResources.clear();
-    this.totalTimeIndexMemCost = 0;
+    this.memoryBlock.setUsedMemoryInBytes(0);
     this.degradedTimeIndexNum = 0;
   }
 
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/LocalSinkChannelTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/LocalSinkChannelTest.java
index 8d9c4b9cd65..3ec95a0205a 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/LocalSinkChannelTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/LocalSinkChannelTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.iotdb.db.queryengine.execution.exchange;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.db.queryengine.common.FragmentInstanceId;
 import org.apache.iotdb.db.queryengine.execution.exchange.MPPDataExchangeManager.SinkListener;
 import org.apache.iotdb.db.queryengine.execution.exchange.sink.LocalSinkChannel;
@@ -45,8 +46,9 @@ public class LocalSinkChannelTest {
 
     // Construct a mock LocalMemoryManager with capacity 5 * mockTsBlockSize per query.
     LocalMemoryManager mockLocalMemoryManager = Mockito.mock(LocalMemoryManager.class);
+    MemoryManager memoryManager = Mockito.spy(new MemoryManager(10 * mockTsBlockSize));
     MemoryPool spyMemoryPool =
-        Mockito.spy(new MemoryPool("test", 10 * mockTsBlockSize, 5 * mockTsBlockSize));
+        Mockito.spy(new MemoryPool("test", memoryManager, 5 * mockTsBlockSize));
     Mockito.when(mockLocalMemoryManager.getQueryPool()).thenReturn(spyMemoryPool);
     // Construct a mock SinkListener.
     SinkListener mockSinkListener = Mockito.mock(SinkListener.class);
@@ -136,8 +138,9 @@ public class LocalSinkChannelTest {
 
     // Construct a mock LocalMemoryManager with capacity 5 * mockTsBlockSize per read.
     LocalMemoryManager mockLocalMemoryManager = Mockito.mock(LocalMemoryManager.class);
+    MemoryManager memoryManager = Mockito.spy(new MemoryManager(10 * mockTsBlockSize));
     MemoryPool spyMemoryPool =
-        Mockito.spy(new MemoryPool("test", 10 * mockTsBlockSize, 5 * mockTsBlockSize));
+        Mockito.spy(new MemoryPool("test", memoryManager, 5 * mockTsBlockSize));
     Mockito.when(mockLocalMemoryManager.getQueryPool()).thenReturn(spyMemoryPool);
     // Construct a mock SinkListener.
     SinkListener mockSinkListener = Mockito.mock(SinkListener.class);
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManagerTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManagerTest.java
index 8824f48f138..448a094c046 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManagerTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManagerTest.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TEndPoint;
 import org.apache.iotdb.commons.client.ClientPoolFactory;
 import org.apache.iotdb.commons.client.IClientManager;
 import org.apache.iotdb.commons.client.sync.SyncDataNodeMPPDataExchangeServiceClient;
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.queryengine.execution.exchange.sink.DownStreamChannelIndex;
 import org.apache.iotdb.db.queryengine.execution.exchange.sink.DownStreamChannelLocation;
@@ -55,7 +56,8 @@ public class MPPDataExchangeManagerTest {
 
     // Construct a mock LocalMemoryManager with capacity 5 * mockTsBlockSize per query.
     LocalMemoryManager mockLocalMemoryManager = Mockito.mock(LocalMemoryManager.class);
-    MemoryPool spyMemoryPool = Mockito.spy(new MemoryPool("test", 10240L, 5120L));
+    MemoryManager memoryManager = Mockito.spy(new MemoryManager(10240L));
+    MemoryPool spyMemoryPool = Mockito.spy(new MemoryPool("test", memoryManager, 5120L));
     Mockito.when(mockLocalMemoryManager.getQueryPool()).thenReturn(spyMemoryPool);
 
     MPPDataExchangeManager mppDataExchangeManager =
@@ -111,7 +113,8 @@ public class MPPDataExchangeManagerTest {
 
     // Construct a mock LocalMemoryManager with capacity 5 * mockTsBlockSize per query.
     LocalMemoryManager mockLocalMemoryManager = Mockito.mock(LocalMemoryManager.class);
-    MemoryPool spyMemoryPool = Mockito.spy(new MemoryPool("test", 10240L, 5120L));
+    MemoryManager memoryManager = Mockito.spy(new MemoryManager(10240L));
+    MemoryPool spyMemoryPool = Mockito.spy(new MemoryPool("test", memoryManager, 5120L));
     Mockito.when(mockLocalMemoryManager.getQueryPool()).thenReturn(spyMemoryPool);
 
     MPPDataExchangeManager mppDataExchangeManager =
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SharedTsBlockQueueTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SharedTsBlockQueueTest.java
index c39175f6c97..5bcfd5fc169 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SharedTsBlockQueueTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SharedTsBlockQueueTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.iotdb.db.queryengine.execution.exchange;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.db.queryengine.execution.memory.LocalMemoryManager;
 import org.apache.iotdb.db.queryengine.execution.memory.MemoryPool;
 import org.apache.iotdb.mpp.rpc.thrift.TFragmentInstanceId;
@@ -43,8 +44,9 @@ public class SharedTsBlockQueueTest {
 
     // Construct a mock LocalMemoryManager with capacity 5 * mockTsBlockSize per query.
     LocalMemoryManager mockLocalMemoryManager = Mockito.mock(LocalMemoryManager.class);
+    MemoryManager memoryManager = Mockito.spy(new MemoryManager(10 * mockTsBlockSize));
     MemoryPool spyMemoryPool =
-        Mockito.spy(new MemoryPool("test", 10 * mockTsBlockSize, 5 * mockTsBlockSize));
+        Mockito.spy(new MemoryPool("test", memoryManager, 5 * mockTsBlockSize));
     Mockito.when(mockLocalMemoryManager.getQueryPool()).thenReturn(spyMemoryPool);
     SharedTsBlockQueue queue =
         new SharedTsBlockQueue(
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/ShuffleSinkHandleTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/ShuffleSinkHandleTest.java
index 489ec5c9ed6..2b5d7f176be 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/ShuffleSinkHandleTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/ShuffleSinkHandleTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.iotdb.db.queryengine.execution.exchange;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.db.queryengine.common.FragmentInstanceId;
 import org.apache.iotdb.db.queryengine.execution.exchange.sink.DownStreamChannelIndex;
 import org.apache.iotdb.db.queryengine.execution.exchange.sink.LocalSinkChannel;
@@ -48,8 +49,9 @@ public class ShuffleSinkHandleTest {
 
     // Construct a mock LocalMemoryManager with capacity 5 * mockTsBlockSize per read.
     LocalMemoryManager mockLocalMemoryManager = Mockito.mock(LocalMemoryManager.class);
+    MemoryManager memoryManager = Mockito.spy(new MemoryManager(10 * mockTsBlockSize));
     MemoryPool spyMemoryPool =
-        Mockito.spy(new MemoryPool("test", 10 * mockTsBlockSize, 5 * mockTsBlockSize));
+        Mockito.spy(new MemoryPool("test", memoryManager, 5 * mockTsBlockSize));
     Mockito.when(mockLocalMemoryManager.getQueryPool()).thenReturn(spyMemoryPool);
     // Construct a mock SinkListener.
     MPPDataExchangeManager.SinkListener mockSinkListener =
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SinkChannelTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SinkChannelTest.java
index 573d56fdd2d..f59dd9925aa 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SinkChannelTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SinkChannelTest.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TEndPoint;
 import org.apache.iotdb.commons.client.IClientManager;
 import org.apache.iotdb.commons.client.exception.ClientManagerException;
 import org.apache.iotdb.commons.client.sync.SyncDataNodeMPPDataExchangeServiceClient;
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.queryengine.common.FragmentInstanceId;
 import org.apache.iotdb.db.queryengine.execution.exchange.MPPDataExchangeManager.SinkListener;
@@ -522,10 +523,10 @@ public class SinkChannelTest {
 
     // Construct a mock LocalMemoryManager that returns blocked futures.
     LocalMemoryManager mockLocalMemoryManager = Mockito.mock(LocalMemoryManager.class);
+    MemoryManager memoryManager =
+        Mockito.spy(new MemoryManager(numOfMockTsBlock * mockTsBlockSize));
     MemoryPool spyMemoryPool =
-        Mockito.spy(
-            new MemoryPool(
-                "test", numOfMockTsBlock * mockTsBlockSize, numOfMockTsBlock * mockTsBlockSize));
+        Mockito.spy(new MemoryPool("test", memoryManager, numOfMockTsBlock * mockTsBlockSize));
     Mockito.when(mockLocalMemoryManager.getQueryPool()).thenReturn(spyMemoryPool);
 
     // Construct a mock SinkListener.
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SourceHandleTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SourceHandleTest.java
index ee849337206..85d1abefb0c 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SourceHandleTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/exchange/SourceHandleTest.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TEndPoint;
 import org.apache.iotdb.commons.client.IClientManager;
 import org.apache.iotdb.commons.client.exception.ClientManagerException;
 import org.apache.iotdb.commons.client.sync.SyncDataNodeMPPDataExchangeServiceClient;
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.queryengine.common.FragmentInstanceId;
 import org.apache.iotdb.db.queryengine.execution.exchange.MPPDataExchangeManager.SourceHandleListener;
@@ -57,13 +58,16 @@ public class SourceHandleTest {
 
   @BeforeClass
   public static void beforeClass() {
-    maxBytesPerFI = IoTDBDescriptor.getInstance().getConfig().getMaxBytesPerFragmentInstance();
-    IoTDBDescriptor.getInstance().getConfig().setMaxBytesPerFragmentInstance(5 * MOCK_TSBLOCK_SIZE);
+    maxBytesPerFI =
+        IoTDBDescriptor.getInstance().getMemoryConfig().getMaxBytesPerFragmentInstance();
+    IoTDBDescriptor.getInstance()
+        .getMemoryConfig()
+        .setMaxBytesPerFragmentInstance(5 * MOCK_TSBLOCK_SIZE);
   }
 
   @AfterClass
   public static void afterClass() {
-    IoTDBDescriptor.getInstance().getConfig().setMaxBytesPerFragmentInstance(maxBytesPerFI);
+    IoTDBDescriptor.getInstance().getMemoryConfig().setMaxBytesPerFragmentInstance(maxBytesPerFI);
   }
 
   @Test
@@ -193,8 +197,9 @@ public class SourceHandleTest {
 
     // Construct a mock LocalMemoryManager with capacity 5 * MOCK_TSBLOCK_SIZE per query.
     LocalMemoryManager mockLocalMemoryManager = Mockito.mock(LocalMemoryManager.class);
+    MemoryManager memoryManager = Mockito.spy(new MemoryManager(10 * MOCK_TSBLOCK_SIZE));
     MemoryPool spyMemoryPool =
-        Mockito.spy(new MemoryPool("test", 10 * MOCK_TSBLOCK_SIZE, 5 * MOCK_TSBLOCK_SIZE));
+        Mockito.spy(new MemoryPool("test", memoryManager, 5 * MOCK_TSBLOCK_SIZE));
     Mockito.when(mockLocalMemoryManager.getQueryPool()).thenReturn(spyMemoryPool);
     IClientManager<TEndPoint, SyncDataNodeMPPDataExchangeServiceClient> mockClientManager =
         Mockito.mock(IClientManager.class);
@@ -239,7 +244,7 @@ public class SourceHandleTest {
     long maxBytesCanReserve =
         Math.min(
             5 * MOCK_TSBLOCK_SIZE,
-            IoTDBDescriptor.getInstance().getConfig().getMaxBytesPerFragmentInstance());
+            IoTDBDescriptor.getInstance().getMemoryConfig().getMaxBytesPerFragmentInstance());
     sourceHandle.setMaxBytesCanReserve(maxBytesCanReserve);
     Assert.assertFalse(sourceHandle.isBlocked().isDone());
     Assert.assertFalse(sourceHandle.isAborted());
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/memory/MemoryPoolTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/memory/MemoryPoolTest.java
index bae3c0643f4..ebcf2abf4e3 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/memory/MemoryPoolTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/memory/MemoryPoolTest.java
@@ -19,10 +19,13 @@
 
 package org.apache.iotdb.db.queryengine.execution.memory;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mockito;
 
 public class MemoryPoolTest {
 
@@ -35,7 +38,8 @@ public class MemoryPoolTest {
 
   @Before
   public void before() {
-    pool = new MemoryPool("test", 1024L, 512L);
+    MemoryManager memoryManager = Mockito.spy(new MemoryManager(1024L));
+    pool = new MemoryPool("test", memoryManager, 512L);
     pool.registerPlanNodeIdToQueryMemoryMap(QUERY_ID, FRAGMENT_INSTANCE_ID, PLAN_NODE_ID);
   }
 
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCacheTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCacheTest.java
index e04a16a2ff0..2a22c20d832 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCacheTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCacheTest.java
@@ -19,13 +19,14 @@
 
 package org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.cache;
 
+import org.apache.iotdb.commons.memory.MemoryManager;
 import org.apache.iotdb.commons.schema.column.ColumnHeader;
 import org.apache.iotdb.commons.schema.table.TsTable;
 import org.apache.iotdb.commons.schema.table.column.AttributeColumnSchema;
 import org.apache.iotdb.commons.schema.table.column.FieldColumnSchema;
 import org.apache.iotdb.commons.schema.table.column.TagColumnSchema;
 import org.apache.iotdb.commons.schema.table.column.TimeColumnSchema;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.schemaengine.table.DataNodeTableCache;
 
@@ -57,7 +58,8 @@ import static org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.T
 
 public class TableDeviceSchemaCacheTest {
 
-  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
 
   private static long originMemConfig;
 
@@ -144,15 +146,24 @@ public class TableDeviceSchemaCacheTest {
     DataNodeTableCache.getInstance().preUpdateTable(database1, testTable2);
     DataNodeTableCache.getInstance().commitUpdateTable(database1, table2);
 
-    originMemConfig = config.getAllocateMemoryForSchemaCache();
-    config.setAllocateMemoryForSchemaCache(1300L);
+    originMemConfig = memoryConfig.getSchemaCacheMemoryManager().getTotalMemorySizeInBytes();
+    changeSchemaCacheMemorySize(1300L);
   }
 
   @AfterClass
   public static void clearEnvironment() {
     DataNodeTableCache.getInstance().invalid(database1);
     DataNodeTableCache.getInstance().invalid(database2);
-    config.setAllocateMemoryForSchemaCache(originMemConfig);
+    changeSchemaCacheMemorySize(originMemConfig);
+  }
+
+  private static void changeSchemaCacheMemorySize(long size) {
+    MemoryManager memoryManager = memoryConfig.getSchemaEngineMemoryManager();
+    MemoryManager schemaCacheMemoryManager = memoryConfig.getSchemaCacheMemoryManager();
+    schemaCacheMemoryManager.clearAll();
+    memoryManager.releaseChildMemoryManager("schemaCache");
+    schemaCacheMemoryManager = memoryManager.getOrCreateMemoryManager("schemaCache", size);
+    memoryConfig.setSchemaCacheMemoryManager(schemaCacheMemoryManager);
   }
 
   @After
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/CompactionWorkerTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/CompactionWorkerTest.java
index df433c2fa21..11121d5bc01 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/CompactionWorkerTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/CompactionWorkerTest.java
@@ -55,13 +55,13 @@ public class CompactionWorkerTest {
   public void setUp()
       throws IOException, WriteProcessException, MetadataException, InterruptedException {
     SystemInfo.getInstance().getCompactionFileNumCost().set(0);
-    SystemInfo.getInstance().getCompactionMemoryCost().set(0);
+    SystemInfo.getInstance().getCompactionMemoryBlock().setUsedMemoryInBytes(0);
   }
 
   @After
   public void teardown() {
     SystemInfo.getInstance().getCompactionFileNumCost().set(0);
-    SystemInfo.getInstance().getCompactionMemoryCost().set(0);
+    SystemInfo.getInstance().getCompactionMemoryBlock().setUsedMemoryInBytes(0);
   }
 
   @Test
@@ -109,7 +109,8 @@ public class CompactionWorkerTest {
             });
     thread.start();
     thread.join(TimeUnit.SECONDS.toMillis(2));
-    Assert.assertEquals(0, SystemInfo.getInstance().getCompactionMemoryCost().get());
+    Assert.assertEquals(
+        0, SystemInfo.getInstance().getCompactionMemoryBlock().getUsedMemoryInBytes());
     Assert.assertEquals(0, SystemInfo.getInstance().getCompactionFileNumCost().get());
     for (TsFileResource tsFileResource : sequenceFiles) {
       Assert.assertEquals(TsFileResourceStatus.NORMAL, tsFileResource.getStatus());
@@ -165,7 +166,8 @@ public class CompactionWorkerTest {
               });
       thread.start();
       thread.join(TimeUnit.SECONDS.toMillis(2));
-      Assert.assertEquals(0, SystemInfo.getInstance().getCompactionMemoryCost().get());
+      Assert.assertEquals(
+          0, SystemInfo.getInstance().getCompactionMemoryBlock().getUsedMemoryInBytes());
       Assert.assertEquals(0, SystemInfo.getInstance().getCompactionFileNumCost().get());
       for (TsFileResource tsFileResource : sequenceFiles) {
         Assert.assertEquals(TsFileResourceStatus.NORMAL, tsFileResource.getStatus());
@@ -219,7 +221,8 @@ public class CompactionWorkerTest {
             });
     thread.start();
     thread.join(TimeUnit.SECONDS.toMillis(2));
-    Assert.assertEquals(0, SystemInfo.getInstance().getCompactionMemoryCost().get());
+    Assert.assertEquals(
+        0, SystemInfo.getInstance().getCompactionMemoryBlock().getUsedMemoryInBytes());
     Assert.assertEquals(0, SystemInfo.getInstance().getCompactionFileNumCost().get());
     for (TsFileResource tsFileResource : sequenceFiles) {
       Assert.assertEquals(TsFileResourceStatus.NORMAL, tsFileResource.getStatus());
@@ -258,7 +261,8 @@ public class CompactionWorkerTest {
             });
     thread.start();
     thread.join(TimeUnit.SECONDS.toMillis(2));
-    Assert.assertEquals(0, SystemInfo.getInstance().getCompactionMemoryCost().get());
+    Assert.assertEquals(
+        0, SystemInfo.getInstance().getCompactionMemoryBlock().getUsedMemoryInBytes());
     Assert.assertEquals(0, SystemInfo.getInstance().getCompactionFileNumCost().get());
     for (TsFileResource tsFileResource : sequenceFiles) {
       Assert.assertEquals(TsFileResourceStatus.NORMAL, tsFileResource.getStatus());
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/FastCrossCompactionPerformerTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/FastCrossCompactionPerformerTest.java
index 7c4dd962e85..a8c6b4cb5c9 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/FastCrossCompactionPerformerTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/FastCrossCompactionPerformerTest.java
@@ -4671,7 +4671,7 @@ public class FastCrossCompactionPerformerTest extends AbstractCompactionTest {
         SystemInfo.getInstance().getTotalFileLimitForCompaction();
     SystemInfo.getInstance().setTotalFileLimitForCompactionTask(15);
     SystemInfo.getInstance().getCompactionFileNumCost().set(0);
-    SystemInfo.getInstance().getCompactionMemoryCost().set(0);
+    SystemInfo.getInstance().getCompactionMemoryBlock().setUsedMemoryInBytes(0);
     try {
       createFiles(6, 2, 3, 300, 0, 0, 50, 50, false, true);
       createFiles(6, 2, 3, 300, 0, 0, 50, 50, false, false);
@@ -4696,7 +4696,8 @@ public class FastCrossCompactionPerformerTest extends AbstractCompactionTest {
       Assert.assertNotNull(takeTask);
       worker.processOneCompactionTask(takeTask);
       Assert.assertEquals(0, SystemInfo.getInstance().getCompactionFileNumCost().get());
-      Assert.assertEquals(0, SystemInfo.getInstance().getCompactionMemoryCost().get());
+      Assert.assertEquals(
+          0, SystemInfo.getInstance().getCompactionMemoryBlock().getUsedMemoryInBytes());
     } finally {
       SystemInfo.getInstance()
           .setTotalFileLimitForCompactionTask(oldMaxCrossCompactionCandidateFileNum);
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/cross/CrossSpaceCompactionSelectorTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/cross/CrossSpaceCompactionSelectorTest.java
index 02408e24c80..a17d52e75f8 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/cross/CrossSpaceCompactionSelectorTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/cross/CrossSpaceCompactionSelectorTest.java
@@ -192,7 +192,7 @@ public class CrossSpaceCompactionSelectorTest extends AbstractCompactionTest {
     int oldMaxFileNumForCompaction = SystemInfo.getInstance().getTotalFileLimitForCompaction();
     SystemInfo.getInstance().setTotalFileLimitForCompactionTask(1);
     SystemInfo.getInstance().getCompactionFileNumCost().set(0);
-    SystemInfo.getInstance().getCompactionMemoryCost().set(0);
+    SystemInfo.getInstance().getCompactionMemoryBlock().setUsedMemoryInBytes(0);
     try {
       createFiles(19, 2, 3, 50, 0, 10000, 50, 50, false, true);
       createFiles(1, 2, 3, 3000, 0, 10000, 50, 50, false, false);
@@ -233,7 +233,8 @@ public class CrossSpaceCompactionSelectorTest extends AbstractCompactionTest {
               });
       thread.start();
       thread.join(TimeUnit.SECONDS.toMillis(2));
-      Assert.assertEquals(0, SystemInfo.getInstance().getCompactionMemoryCost().get());
+      Assert.assertEquals(
+          0, SystemInfo.getInstance().getCompactionMemoryBlock().getUsedMemoryInBytes());
       Assert.assertEquals(0, SystemInfo.getInstance().getCompactionFileNumCost().get());
       for (TsFileResource resource : seqResources) {
         Assert.assertEquals(TsFileResourceStatus.NORMAL, resource.getStatus());
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionClearUtils.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionClearUtils.java
index 71f05ca8ce5..b9dd76c1451 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionClearUtils.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionClearUtils.java
@@ -49,7 +49,7 @@ public class CompactionClearUtils {
     deleteAllFilesInOneDirBySuffix("target", CompactionLogger.INNER_COMPACTION_LOG_NAME_SUFFIX);
     deleteAllFilesInOneDirBySuffix("target", CompactionLogger.CROSS_COMPACTION_LOG_NAME_SUFFIX);
     // clean cache
-    if (IoTDBDescriptor.getInstance().getConfig().isMetaDataCacheEnable()) {
+    if (IoTDBDescriptor.getInstance().getMemoryConfig().isMetaDataCacheEnable()) {
       ChunkCache.getInstance().clear();
       TimeSeriesMetadataCache.getInstance().clear();
       BloomFilterCache.getInstance().clear();
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionTaskQueueTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionTaskQueueTest.java
index d6d341acd40..8dd848505bc 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionTaskQueueTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionTaskQueueTest.java
@@ -54,7 +54,7 @@ public class CompactionTaskQueueTest extends AbstractCompactionTest {
   @Before
   public void setup()
       throws IOException, InterruptedException, MetadataException, WriteProcessException {
-    SystemInfo.getInstance().getCompactionMemoryCost().set(0);
+    SystemInfo.getInstance().getCompactionMemoryBlock().setUsedMemoryInBytes(0);
     SystemInfo.getInstance().getCompactionFileNumCost().set(0);
     SystemInfo.getInstance().setMemorySizeForCompaction(2000);
     SystemInfo.getInstance().setTotalFileLimitForCompactionTask(50);
@@ -63,7 +63,7 @@ public class CompactionTaskQueueTest extends AbstractCompactionTest {
 
   @After
   public void teardown() throws StorageEngineException, IOException {
-    SystemInfo.getInstance().getCompactionMemoryCost().set(0);
+    SystemInfo.getInstance().getCompactionMemoryBlock().setUsedMemoryInBytes(0);
     SystemInfo.getInstance().getCompactionFileNumCost().set(0);
     SystemInfo.getInstance().setMemorySizeForCompaction(originalMemorySizeForCompaction);
     SystemInfo.getInstance().setTotalFileLimitForCompactionTask(originalFileNumLimitForCompaction);
@@ -80,7 +80,8 @@ public class CompactionTaskQueueTest extends AbstractCompactionTest {
     AbstractCompactionTask task = queue.take();
     Assert.assertNotNull(task);
     releaseTaskOccupiedResources(task);
-    Assert.assertEquals(0, SystemInfo.getInstance().getCompactionMemoryCost().get());
+    Assert.assertEquals(
+        0, SystemInfo.getInstance().getCompactionMemoryBlock().getUsedMemoryInBytes());
     Assert.assertEquals(0, SystemInfo.getInstance().getCompactionFileNumCost().get());
   }
 
@@ -118,7 +119,8 @@ public class CompactionTaskQueueTest extends AbstractCompactionTest {
     while (outTaskNum.get() != 3) {
       Thread.sleep(TimeUnit.MILLISECONDS.toMillis(100));
     }
-    Assert.assertEquals(0, SystemInfo.getInstance().getCompactionMemoryCost().get());
+    Assert.assertEquals(
+        0, SystemInfo.getInstance().getCompactionMemoryBlock().getUsedMemoryInBytes());
     Assert.assertEquals(0, SystemInfo.getInstance().getCompactionFileNumCost().get());
     for (Thread thread : threadList) {
       thread.interrupt();
@@ -161,7 +163,8 @@ public class CompactionTaskQueueTest extends AbstractCompactionTest {
     while (outTaskNum.get() != 3) {
       Thread.sleep(TimeUnit.MILLISECONDS.toMillis(100));
     }
-    Assert.assertEquals(0, SystemInfo.getInstance().getCompactionMemoryCost().get());
+    Assert.assertEquals(
+        0, SystemInfo.getInstance().getCompactionMemoryBlock().getUsedMemoryInBytes());
     Assert.assertEquals(0, SystemInfo.getInstance().getCompactionFileNumCost().get());
     for (Thread thread : threadList) {
       thread.interrupt();
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/rescon/memory/ResourceManagerTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/rescon/memory/ResourceManagerTest.java
index 53f399f5aa5..62de76b2e69 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/rescon/memory/ResourceManagerTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/rescon/memory/ResourceManagerTest.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.db.storageengine.rescon.memory;
 
 import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.commons.exception.MetadataException;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.exception.StorageEngineException;
@@ -77,13 +78,16 @@ public class ResourceManagerTest {
   List<TsFileResource> unseqResources = new ArrayList<>();
 
   private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig MEMORY_CONFIG =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private final TsFileResourceManager tsFileResourceManager = TsFileResourceManager.getInstance();
   private long prevTimeIndexMemoryThreshold;
   private TimeIndexLevel timeIndexLevel;
 
   @Before
   public void setUp() throws IOException, WriteProcessException, MetadataException {
-    prevTimeIndexMemoryThreshold = CONFIG.getAllocateMemoryForTimeIndex();
+    prevTimeIndexMemoryThreshold =
+        MEMORY_CONFIG.getTimeIndexMemoryManager().getTotalMemorySizeInBytes();
     timeIndexLevel = CONFIG.getTimeIndexLevel();
     prepareSeries();
   }
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/rescon/memory/TimePartitionManagerTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/rescon/memory/TimePartitionManagerTest.java
index c8cd83b253e..7be3dc0191d 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/rescon/memory/TimePartitionManagerTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/rescon/memory/TimePartitionManagerTest.java
@@ -21,7 +21,7 @@ package org.apache.iotdb.db.storageengine.rescon.memory;
 
 import org.apache.iotdb.commons.consensus.DataRegionId;
 import org.apache.iotdb.commons.exception.MetadataException;
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.exception.StorageEngineException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
@@ -41,14 +41,16 @@ import static org.junit.Assert.assertTrue;
 public class TimePartitionManagerTest {
 
   private final TimePartitionManager timePartitionManager = TimePartitionManager.getInstance();
-  private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig MEMORY_CONFIG =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private long prevTimePartitionInfoMemoryThreshold;
 
   public TimePartitionManagerTest() throws QueryProcessException {}
 
   @Before
   public void setUp() throws IOException, WriteProcessException, MetadataException {
-    prevTimePartitionInfoMemoryThreshold = CONFIG.getAllocateMemoryForTimePartitionInfo();
+    prevTimePartitionInfoMemoryThreshold =
+        MEMORY_CONFIG.getTimePartitionInfoMemoryManager().getTotalMemorySizeInBytes();
     timePartitionManager.setTimePartitionInfoMemoryThreshold(100L);
   }
 
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
index e4d133a81cd..4326309a53a 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.commons.conf.CommonConfig;
 import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.commons.exception.StartupException;
 import org.apache.iotdb.commons.udf.service.UDFManagementService;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.exception.StorageEngineException;
@@ -78,6 +79,8 @@ public class EnvironmentUtils {
 
   private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
   private static final CommonConfig commonConfig = CommonDescriptor.getInstance().getConfig();
+  private static final DataNodeMemoryConfig memoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
   private static final TierManager tierManager = TierManager.getInstance();
 
   public static long TEST_QUERY_JOB_ID = 1;
@@ -138,7 +141,7 @@ public class EnvironmentUtils {
     IoTDBDescriptor.getInstance().getConfig().setEnableMQTTService(false);
 
     // clean cache
-    if (config.isMetaDataCacheEnable()) {
+    if (memoryConfig.isMetaDataCacheEnable()) {
       ChunkCache.getInstance().clear();
       TimeSeriesMetadataCache.getInstance().clear();
       BloomFilterCache.getInstance().clear();
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/datastructure/PrimitiveArrayManagerTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/datastructure/PrimitiveArrayManagerTest.java
index cb0a030b9f0..624ff6eb012 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/datastructure/PrimitiveArrayManagerTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/datastructure/PrimitiveArrayManagerTest.java
@@ -19,7 +19,7 @@
 
 package org.apache.iotdb.db.utils.datastructure;
 
-import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.DataNodeMemoryConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.storageengine.rescon.memory.PrimitiveArrayManager;
 
@@ -31,7 +31,8 @@ import org.junit.Test;
 import static org.apache.iotdb.db.storageengine.rescon.memory.PrimitiveArrayManager.ARRAY_SIZE;
 
 public class PrimitiveArrayManagerTest {
-  private IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private DataNodeMemoryConfig dataNodeMemoryConfig =
+      IoTDBDescriptor.getInstance().getMemoryConfig();
 
   @Test
   public void testGetArrayRowCount() {
@@ -53,8 +54,7 @@ public class PrimitiveArrayManagerTest {
 
     /** threshold total size of arrays for all data types */
     double POOLED_ARRAYS_MEMORY_THRESHOLD =
-        config.getAllocateMemoryForStorageEngine()
-            * config.getBufferedArraysMemoryProportion()
+        dataNodeMemoryConfig.getBufferedArraysMemoryManager().getTotalMemorySizeInBytes()
             / AMPLIFICATION_FACTOR;
     // LIMITS should be updated if (TOTAL_ALLOCATION_REQUEST_COUNT.get() > limitUpdateThreshold)
     int totalDataTypeSize = 0;
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/concurrent/ThreadName.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/concurrent/ThreadName.java
index ec4a1a7c2cd..3965622078c 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/concurrent/ThreadName.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/concurrent/ThreadName.java
@@ -149,6 +149,7 @@ public enum ThreadName {
   SUBSCRIPTION_RUNTIME_META_SYNCER("Subscription-Runtime-Meta-Syncer"),
   WINDOW_EVALUATION_SERVICE("WindowEvaluationTaskPoolManager"),
   STATEFUL_TRIGGER_INFORMATION_UPDATER("Stateful-Trigger-Information-Updater"),
+  MEMORY_PERIODICAL_JOB_EXECUTOR("Memory-Periodical-Job-Executor"),
   // -------------------------- JVM --------------------------
   // NOTICE: The thread name of jvm cannot be edited here!
   // We list the thread name here just for distinguishing what module the thread belongs to.
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java
index 2afe9bbdeb4..5eee1b68ef7 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java
@@ -24,12 +24,16 @@ import org.apache.iotdb.commons.enums.PipeRemainingTimeRateAverageTime;
 import org.apache.iotdb.commons.utils.CommonDateTimeUtils;
 import org.apache.iotdb.confignode.rpc.thrift.TGlobalConfig;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.Optional;
 
 public class CommonDescriptor {
 
+  private static final Logger LOGGER = LoggerFactory.getLogger(CommonDescriptor.class);
   private final CommonConfig config = new CommonConfig();
 
   private CommonDescriptor() {}
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/AtomicLongMemoryBlock.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/AtomicLongMemoryBlock.java
new file mode 100644
index 00000000000..1376d8ddb6d
--- /dev/null
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/AtomicLongMemoryBlock.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.memory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class AtomicLongMemoryBlock extends IMemoryBlock {
+  private static final Logger LOGGER = LoggerFactory.getLogger(AtomicLongMemoryBlock.class);
+
+  /** The memory usage in byte of this memory block */
+  protected final AtomicLong usedMemoryInBytes = new AtomicLong(0);
+
+  public AtomicLongMemoryBlock(
+      final String name, final MemoryManager memoryManager, final long maxMemorySizeInByte) {
+    this.name = name;
+    this.memoryManager = memoryManager;
+    this.totalMemorySizeInBytes = maxMemorySizeInByte;
+    this.memoryBlockType = MemoryBlockType.NONE;
+  }
+
+  public AtomicLongMemoryBlock(
+      final String name,
+      final MemoryManager memoryManager,
+      final long maxMemorySizeInByte,
+      final MemoryBlockType memoryBlockType) {
+    this.name = name;
+    this.memoryManager = memoryManager;
+    this.totalMemorySizeInBytes = maxMemorySizeInByte;
+    this.memoryBlockType = memoryBlockType;
+  }
+
+  @Override
+  public long forceAllocateWithoutLimitation(long sizeInByte) {
+    return usedMemoryInBytes.addAndGet(sizeInByte);
+  }
+
+  @Override
+  public boolean allocate(long sizeInByte) {
+    AtomicBoolean result = new AtomicBoolean(false);
+    usedMemoryInBytes.updateAndGet(
+        memCost -> {
+          if (memCost + sizeInByte > totalMemorySizeInBytes) {
+            return memCost;
+          }
+          result.set(true);
+          return memCost + sizeInByte;
+        });
+    return result.get();
+  }
+
+  @Override
+  public boolean allocateIfSufficient(final long sizeInByte, final double maxRatio) {
+    AtomicBoolean result = new AtomicBoolean(false);
+    usedMemoryInBytes.updateAndGet(
+        memCost -> {
+          if (memCost + sizeInByte > totalMemorySizeInBytes * maxRatio) {
+            return memCost;
+          }
+          result.set(true);
+          return memCost + sizeInByte;
+        });
+    return result.get();
+  }
+
+  @Override
+  public boolean allocateUntilAvailable(long sizeInByte, long retryIntervalInMillis)
+      throws InterruptedException {
+    long originSize = usedMemoryInBytes.get();
+    while (true) {
+      boolean canUpdate = originSize + sizeInByte <= totalMemorySizeInBytes;
+      if (canUpdate && usedMemoryInBytes.compareAndSet(originSize, originSize + sizeInByte)) {
+        break;
+      }
+      Thread.sleep(TimeUnit.MILLISECONDS.toMillis(retryIntervalInMillis));
+      originSize = usedMemoryInBytes.get();
+    }
+    return true;
+  }
+
+  @Override
+  public long release(long sizeInByte) {
+    return usedMemoryInBytes.updateAndGet(
+        memCost -> {
+          if (sizeInByte > memCost) {
+            LOGGER.warn(
+                "The memory cost to be released is larger than the memory cost of memory block {}",
+                this);
+            return 0;
+          }
+          return memCost - sizeInByte;
+        });
+  }
+
+  @Override
+  public void setUsedMemoryInBytes(long usedMemoryInBytes) {
+    this.usedMemoryInBytes.set(usedMemoryInBytes);
+  }
+
+  public long getUsedMemoryInBytes() {
+    return usedMemoryInBytes.get();
+  }
+
+  /** Get the free memory in byte of this memory block */
+  public long getFreeMemoryInBytes() {
+    return totalMemorySizeInBytes - usedMemoryInBytes.get();
+  }
+
+  @Override
+  public String toString() {
+    return "IoTDBMemoryBlock{"
+        + "name="
+        + name
+        + ", isReleased="
+        + isReleased
+        + ", memoryBlockType="
+        + memoryBlockType
+        + ", totalMemorySizeInBytes="
+        + totalMemorySizeInBytes
+        + ", usedMemoryInBytes="
+        + usedMemoryInBytes
+        + '}';
+  }
+
+  @Override
+  public void close() throws Exception {
+    if (memoryManager != null) {
+      memoryManager.release(this);
+    }
+  }
+}
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/IMemoryBlock.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/IMemoryBlock.java
new file mode 100644
index 00000000000..332e82336ac
--- /dev/null
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/IMemoryBlock.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.memory;
+
+import org.apache.iotdb.commons.utils.TestOnly;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class IMemoryBlock implements AutoCloseable {
+  private static final Logger LOGGER = LoggerFactory.getLogger(IMemoryBlock.class);
+
+  /** The memory manager that manages this memory block */
+  protected MemoryManager memoryManager;
+
+  /** The name of this memory block */
+  protected String name;
+
+  /** The type of this memory block */
+  protected MemoryBlockType memoryBlockType;
+
+  /** The flag that indicates whether this memory block is released */
+  protected volatile boolean isReleased = false;
+
+  /** The total memory size in byte of this memory block */
+  protected long totalMemorySizeInBytes;
+
+  /**
+   * Forcibly allocate memory without the limit of totalMemorySizeInBytes
+   *
+   * @param sizeInByte the size of memory to be allocated, should be positive
+   * @return the number of bytes actually allocated
+   */
+  public abstract long forceAllocateWithoutLimitation(final long sizeInByte);
+
+  /**
+   * Allocate memory managed by this memory block
+   *
+   * @param sizeInByte the size of memory to be allocated, should be positive
+   */
+  public abstract boolean allocate(final long sizeInByte);
+
+  /**
+   * Allocate memory managed by this memory block. if the currently used ratio is already above
+   * maxRatio, the allocation will fail".
+   *
+   * @param sizeInByte the size of memory to be allocated, should be positive
+   * @param maxRatio the maximum ratio of memory can be allocated
+   */
+  public abstract boolean allocateIfSufficient(final long sizeInByte, final double maxRatio);
+
+  /**
+   * Allocate memory managed by this memory block until the required memory is available
+   *
+   * @param sizeInByte the size of memory to be allocated, should be positive
+   * @param retryIntervalInMillis the time interval to wait after each allocation failure
+   */
+  public abstract boolean allocateUntilAvailable(final long sizeInByte, long retryIntervalInMillis)
+      throws InterruptedException;
+
+  /**
+   * Try to release memory managed by this memory block
+   *
+   * @param sizeInByte the size of memory to be released, should be positive
+   * @return the used size after release, zero if the release fails
+   */
+  public abstract long release(final long sizeInByte);
+
+  /**
+   * Try to set memory usage in byte of this memory block (for test only)
+   *
+   * @param usedMemoryInBytes the memory usage in byte to be set
+   */
+  @TestOnly
+  public abstract void setUsedMemoryInBytes(final long usedMemoryInBytes);
+
+  /** Get the memory usage in byte of this memory block */
+  public abstract long getUsedMemoryInBytes();
+
+  /** Get the free memory in byte of this memory block */
+  public abstract long getFreeMemoryInBytes();
+
+  /** Get the name of memory block */
+  public String getName() {
+    return name;
+  }
+
+  /** Update maximum memory size in byte of this memory block */
+  public void setTotalMemorySizeInBytes(final long totalMemorySizeInBytes) {
+    this.totalMemorySizeInBytes = totalMemorySizeInBytes;
+  }
+
+  /** Get the maximum memory size in byte of this memory block */
+  public long getTotalMemorySizeInBytes() {
+    return totalMemorySizeInBytes;
+  }
+
+  /** Get whether this memory block is released */
+  public boolean isReleased() {
+    return isReleased;
+  }
+
+  /** Mark this memory block as released */
+  public void markAsReleased() {
+    isReleased = true;
+  }
+
+  /** Get the type of this memory block */
+  public MemoryBlockType getMemoryBlockType() {
+    return memoryBlockType;
+  }
+
+  public void print(int indent) {
+    StringBuilder sb = new StringBuilder();
+    for (int i = 0; i < indent; i++) {
+      sb.append("  ");
+    }
+    sb.append(this);
+    LOGGER.info(sb.toString());
+  }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/LocalMemoryManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryBlockType.java
similarity index 54%
copy from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/LocalMemoryManager.java
copy to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryBlockType.java
index bbd33eb28ca..6a20600713e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/LocalMemoryManager.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryBlockType.java
@@ -17,27 +17,12 @@
  * under the License.
  */
 
-package org.apache.iotdb.db.queryengine.execution.memory;
+package org.apache.iotdb.commons.memory;
 
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-
-/**
- * Manages memory of a data node. The memory is divided into two memory pools so that the memory for
- * read and for write can be isolated.
- */
-public class LocalMemoryManager {
-
-  private final MemoryPool queryPool;
-
-  public LocalMemoryManager() {
-    queryPool =
-        new MemoryPool(
-            "read",
-            IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForDataExchange(),
-            IoTDBDescriptor.getInstance().getConfig().getMaxBytesPerFragmentInstance());
-  }
-
-  public MemoryPool getQueryPool() {
-    return queryPool;
-  }
+public enum MemoryBlockType {
+  NONE,
+  // static memory
+  STATIC,
+  // dynamic memory
+  DYNAMIC,
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/LocalMemoryManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryConfig.java
similarity index 55%
copy from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/LocalMemoryManager.java
copy to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryConfig.java
index bbd33eb28ca..dc1ca4e5473 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/LocalMemoryManager.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryConfig.java
@@ -17,27 +17,27 @@
  * under the License.
  */
 
-package org.apache.iotdb.db.queryengine.execution.memory;
+package org.apache.iotdb.commons.memory;
 
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
+public class MemoryConfig {
+  private final MemoryManager globalMemoryManager =
+      new MemoryManager("GlobalMemoryManager", null, Runtime.getRuntime().totalMemory());
 
-/**
- * Manages memory of a data node. The memory is divided into two memory pools so that the memory for
- * read and for write can be isolated.
- */
-public class LocalMemoryManager {
+  private MemoryConfig() {
+    // singleton
+  }
 
-  private final MemoryPool queryPool;
+  public static MemoryManager global() {
+    return MemoryConfigHolder.INSTANCE.globalMemoryManager;
+  }
 
-  public LocalMemoryManager() {
-    queryPool =
-        new MemoryPool(
-            "read",
-            IoTDBDescriptor.getInstance().getConfig().getAllocateMemoryForDataExchange(),
-            IoTDBDescriptor.getInstance().getConfig().getMaxBytesPerFragmentInstance());
+  public static MemoryConfig getInstance() {
+    return MemoryConfigHolder.INSTANCE;
   }
 
-  public MemoryPool getQueryPool() {
-    return queryPool;
+  private static class MemoryConfigHolder {
+    private static final MemoryConfig INSTANCE = new MemoryConfig();
+
+    private MemoryConfigHolder() {}
   }
 }
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryException.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryException.java
new file mode 100644
index 00000000000..3a85853c31d
--- /dev/null
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryException.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.memory;
+
+import java.util.Objects;
+
+public class MemoryException extends RuntimeException {
+
+  private final long timestamp;
+  private static final long VERSION = 1L;
+
+  public MemoryException(final String message) {
+    super(message);
+    this.timestamp = System.currentTimeMillis();
+  }
+
+  public MemoryException(final String message, final long timeStamp) {
+    super(message);
+    this.timestamp = timeStamp;
+  }
+
+  public MemoryException(final String message, final Throwable cause) {
+    super(message, cause);
+    this.timestamp = System.currentTimeMillis();
+  }
+
+  public long getTimestamp() {
+    return timestamp;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    return obj instanceof MemoryException
+        && Objects.equals(getMessage(), ((MemoryException) obj).getMessage())
+        && Objects.equals(getTimestamp(), ((MemoryException) obj).getTimestamp());
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(getMessage(), getTimestamp());
+  }
+
+  @Override
+  public String toString() {
+    return "MemoryException{" + "message='" + getMessage() + "', timestamp=" + getTimestamp() + "}";
+  }
+}
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryManager.java
new file mode 100644
index 00000000000..03fb10d393a
--- /dev/null
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryManager.java
@@ -0,0 +1,523 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.memory;
+
+import org.apache.iotdb.commons.utils.TestOnly;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.LongUnaryOperator;
+
+public class MemoryManager {
+  private static final Logger LOGGER = LoggerFactory.getLogger(MemoryManager.class);
+
+  /** The max retry times for memory allocation */
+  private static final int MEMORY_ALLOCATE_MAX_RETRIES = 3;
+
+  /** The retry interval for memory allocation */
+  private static final long MEMORY_ALLOCATE_RETRY_INTERVAL_IN_MS = 1000;
+
+  /** The min memory size to allocate */
+  private static final long MEMORY_ALLOCATE_MIN_SIZE_IN_BYTES = 32;
+
+  /** The name of memory manager */
+  private final String name;
+
+  /** Whether memory management is enabled */
+  private final boolean enabled;
+
+  /** The total memory size in byte of memory manager */
+  private volatile long totalMemorySizeInBytes;
+
+  /** The allocated memory size */
+  private volatile long allocatedMemorySizeInBytes = 0L;
+
+  /** The parent memory manager */
+  private final MemoryManager parentMemoryManager;
+
+  /** The child memory manager */
+  private final Map<String, MemoryManager> children = new ConcurrentHashMap<>();
+
+  /** The allocated memory blocks of this memory manager */
+  private final Map<String, IMemoryBlock> allocatedMemoryBlocks = new ConcurrentHashMap<>();
+
+  @TestOnly
+  public MemoryManager(long totalMemorySizeInBytes) {
+    this.name = "Test";
+    this.parentMemoryManager = null;
+    this.totalMemorySizeInBytes = totalMemorySizeInBytes;
+    this.enabled = false;
+  }
+
+  MemoryManager(String name, MemoryManager parentMemoryManager, long totalMemorySizeInBytes) {
+    this.name = name;
+    this.parentMemoryManager = parentMemoryManager;
+    this.totalMemorySizeInBytes = totalMemorySizeInBytes;
+    this.enabled = false;
+  }
+
+  private MemoryManager(
+      String name,
+      MemoryManager parentMemoryManager,
+      long totalMemorySizeInBytes,
+      boolean enabled) {
+    this.name = name;
+    this.parentMemoryManager = parentMemoryManager;
+    this.totalMemorySizeInBytes = totalMemorySizeInBytes;
+    this.enabled = enabled;
+  }
+
+  // region The Methods Of IMemoryBlock Management
+
+  /**
+   * Allocate memory block with exact specified size in bytes
+   *
+   * @param name the name of memory block
+   * @param sizeInBytes the size in bytes of memory block try to allocate
+   * @param type the type of memory block
+   * @return the allocated memory block
+   * @throw MemoryException if fail to allocate after MEMORY_ALLOCATE_MAX_RETRIES retries
+   */
+  public synchronized IMemoryBlock exactAllocate(
+      String name, long sizeInBytes, MemoryBlockType type) {
+    if (!enabled) {
+      return getOrRegisterMemoryBlock(name, sizeInBytes, type);
+    }
+    for (int i = 0; i < MEMORY_ALLOCATE_MAX_RETRIES; i++) {
+      if (totalMemorySizeInBytes - allocatedMemorySizeInBytes >= sizeInBytes) {
+        return getOrRegisterMemoryBlock(name, sizeInBytes, type);
+      }
+
+      try {
+        this.wait(MEMORY_ALLOCATE_RETRY_INTERVAL_IN_MS);
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+        LOGGER.warn("exactAllocate: interrupted while waiting for available memory", e);
+      }
+    }
+
+    throw new MemoryException(
+        String.format(
+            "exactAllocate: failed to allocate memory after %d retries, "
+                + "total memory size %d bytes, used memory size %d bytes, "
+                + "requested memory size %d bytes",
+            MEMORY_ALLOCATE_MAX_RETRIES,
+            totalMemorySizeInBytes,
+            allocatedMemorySizeInBytes,
+            sizeInBytes));
+  }
+
+  /**
+   * Try to allocate memory block with total memory size in bytes
+   *
+   * @param name the name of memory block
+   * @param memoryBlockType the type of memory block
+   */
+  public synchronized IMemoryBlock exactAllocate(String name, MemoryBlockType memoryBlockType) {
+    return exactAllocate(
+        name, totalMemorySizeInBytes - allocatedMemorySizeInBytes, memoryBlockType);
+  }
+
+  /**
+   * Try to allocate memory block with specified size in bytes when the proportion of used memory is
+   * below the given maxRatio.
+   *
+   * @param name the name of memory block
+   * @param sizeInBytes the size in bytes of memory block try to allocate
+   * @param maxRatio the used threshold of allocatedMemorySizeInBytes / totalMemorySizeInBytes, must
+   *     be within [0.0, 1.0
+   * @param memoryBlockType the type of memory block
+   * @return the memory block if success, otherwise null
+   */
+  public synchronized IMemoryBlock exactAllocateIfSufficient(
+      String name, long sizeInBytes, float maxRatio, MemoryBlockType memoryBlockType) {
+    if (maxRatio < 0.0f || maxRatio > 1.0f) {
+      return null;
+    }
+    if (!enabled) {
+      return getOrRegisterMemoryBlock(name, sizeInBytes, memoryBlockType);
+    }
+    if (totalMemorySizeInBytes - allocatedMemorySizeInBytes >= sizeInBytes
+        && (float) allocatedMemorySizeInBytes / totalMemorySizeInBytes < maxRatio) {
+      return exactAllocate(name, sizeInBytes, memoryBlockType);
+    } else {
+      // TODO @spricoder: consider to find more memory in active way
+      LOGGER.debug(
+          "exactAllocateIfSufficient: failed to allocate memory, "
+              + "total memory size {} bytes, used memory size {} bytes, "
+              + "requested memory size {} bytes, used threshold {}",
+          totalMemorySizeInBytes,
+          allocatedMemorySizeInBytes,
+          sizeInBytes,
+          maxRatio);
+    }
+
+    return null;
+  }
+
+  /**
+   * Try to allocate memory block with customAllocateStrategy
+   *
+   * @param name the name of memory block
+   * @param sizeInBytes the size in bytes of memory block try to allocate
+   * @param customAllocateStrategy the custom allocate strategy when memory is insufficient
+   * @param type the type of memory block
+   * @return the memory block if success, otherwise null
+   */
+  public synchronized IMemoryBlock tryAllocate(
+      String name,
+      long sizeInBytes,
+      LongUnaryOperator customAllocateStrategy,
+      MemoryBlockType type) {
+    if (!enabled) {
+      return getOrRegisterMemoryBlock(name, sizeInBytes, type);
+    }
+
+    if (totalMemorySizeInBytes - allocatedMemorySizeInBytes >= sizeInBytes) {
+      return getOrRegisterMemoryBlock(name, sizeInBytes, type);
+    }
+
+    long sizeToAllocateInBytes = sizeInBytes;
+    while (sizeToAllocateInBytes >= MEMORY_ALLOCATE_MIN_SIZE_IN_BYTES) {
+      if (totalMemorySizeInBytes - allocatedMemorySizeInBytes >= sizeToAllocateInBytes) {
+        LOGGER.debug(
+            "tryAllocate: allocated memory, "
+                + "total memory size {} bytes, used memory size {} bytes, "
+                + "original requested memory size {} bytes, "
+                + "actual requested memory size {} bytes",
+            totalMemorySizeInBytes,
+            allocatedMemorySizeInBytes,
+            sizeInBytes,
+            sizeToAllocateInBytes);
+        return getOrRegisterMemoryBlock(name, sizeToAllocateInBytes, type);
+      }
+
+      sizeToAllocateInBytes =
+          Math.max(
+              customAllocateStrategy.applyAsLong(sizeToAllocateInBytes),
+              MEMORY_ALLOCATE_MIN_SIZE_IN_BYTES);
+    }
+
+    // TODO @spricoder: consider to find more memory in active way
+    LOGGER.warn(
+        "tryAllocate: failed to allocate memory, "
+            + "total memory size {} bytes, used memory size {} bytes, "
+            + "requested memory size {} bytes",
+        totalMemorySizeInBytes,
+        allocatedMemorySizeInBytes,
+        sizeInBytes);
+    return null;
+  }
+
+  /**
+   * Try to register memory block with specified size in bytes
+   *
+   * @param name the name of memory block, UNIQUE
+   * @param sizeInBytes the size in bytes of memory block
+   * @param type the type of memory block
+   * @return the memory block
+   */
+  private IMemoryBlock getOrRegisterMemoryBlock(
+      String name, long sizeInBytes, MemoryBlockType type) {
+    if (sizeInBytes < 0) {
+      throw new MemoryException(
+          String.format(
+              "register memory block %s failed: sizeInBytes should be non-negative", name));
+    }
+    return allocatedMemoryBlocks.compute(
+        name,
+        (blockName, block) -> {
+          if (block != null) {
+            if (block.getTotalMemorySizeInBytes() != sizeInBytes) {
+              LOGGER.warn(
+                  "getOrRegisterMemoryBlock failed: memory block {} already exists, "
+                      + "it's size is {}, requested size is {}",
+                  blockName,
+                  block.getTotalMemorySizeInBytes(),
+                  sizeInBytes);
+            }
+            return block;
+          } else {
+            allocatedMemorySizeInBytes += sizeInBytes;
+            return new AtomicLongMemoryBlock(name, this, sizeInBytes, type);
+          }
+        });
+  }
+
+  /**
+   * Release memory block and notify all waiting threads
+   *
+   * @param block the memory block to release
+   */
+  public synchronized void release(IMemoryBlock block) {
+    if (block == null || block.isReleased()) {
+      return;
+    }
+    releaseWithOutNotify(block);
+    this.notifyAll();
+  }
+
+  /**
+   * Release memory block without notify
+   *
+   * @param block the memory block to release
+   */
+  public synchronized void releaseWithOutNotify(IMemoryBlock block) {
+    if (block == null || block.isReleased()) {
+      return;
+    }
+
+    block.markAsReleased();
+    allocatedMemorySizeInBytes -= block.getTotalMemorySizeInBytes();
+    allocatedMemoryBlocks.remove(block.getName());
+    try {
+      block.close();
+    } catch (Exception e) {
+      LOGGER.error("releaseWithOutNotify: failed to close memory block {}", block, e);
+    }
+  }
+
+  // endregion
+
+  // region The Methods Of MemoryManager Management
+
+  /**
+   * Try to create a new memory manager with specified name and total memory size in bytes, then put
+   * it into children map. NOTICE: if there are same name memory manager, it will return the
+   * existing one instead of creating a new one or update the existing one.
+   *
+   * @param name the name of memory manager
+   * @param sizeInBytes the total memory size in bytes of memory manager
+   * @param enabled whether memory management is enabled
+   * @return the memory manager
+   */
+  public synchronized MemoryManager getOrCreateMemoryManager(
+      String name, long sizeInBytes, boolean enabled) {
+    return children.compute(
+        name,
+        (managerName, manager) -> {
+          if (sizeInBytes < 0) {
+            LOGGER.warn("getOrCreateMemoryManager {}: sizeInBytes should be positive", name);
+            return null;
+          }
+          if (manager != null) {
+            LOGGER.debug(
+                "getMemoryManager: memory manager {} already exists, it's size is {}, enabled is {}",
+                managerName,
+                manager.getTotalMemorySizeInBytes(),
+                manager.isEnable());
+            return manager;
+          } else {
+            if (this.enabled
+                && sizeInBytes + this.allocatedMemorySizeInBytes > this.totalMemorySizeInBytes) {
+              LOGGER.warn(
+                  "getOrCreateMemoryManager failed: total memory size {} bytes is less than allocated memory size {} bytes",
+                  sizeInBytes,
+                  allocatedMemorySizeInBytes);
+              return null;
+            }
+            allocatedMemorySizeInBytes += sizeInBytes;
+            return new MemoryManager(name, this, sizeInBytes, enabled);
+          }
+        });
+  }
+
+  /**
+   * Try to create a new memory manager with specified name and total memory size in bytes, then put
+   * it into children map. NOTICE: if there are same name memory manager, it will return the
+   * existing one.
+   *
+   * @param name the name of memory manager
+   * @param totalMemorySizeInBytes the total memory size in bytes of memory manager
+   * @return the memory manager
+   */
+  public synchronized MemoryManager getOrCreateMemoryManager(
+      String name, long totalMemorySizeInBytes) {
+    return getOrCreateMemoryManager(name, totalMemorySizeInBytes, false);
+  }
+
+  /**
+   * Re-allocate memory according to ratio
+   *
+   * @param ratio the ratio of new total memory size to old total memory size
+   */
+  private void reAllocateMemoryAccordingToRatio(double ratio) {
+    // first increase the total memory size of this memory manager
+    this.totalMemorySizeInBytes *= ratio;
+    // then re-allocate memory for all memory blocks
+    for (IMemoryBlock block : allocatedMemoryBlocks.values()) {
+      block.setTotalMemorySizeInBytes((long) (block.getTotalMemorySizeInBytes() * ratio));
+    }
+    // finally re-allocate memory for all child memory managers
+    for (Map.Entry<String, MemoryManager> entry : children.entrySet()) {
+      entry.getValue().reAllocateMemoryAccordingToRatio(ratio);
+    }
+  }
+
+  /**
+   * Get the memory manager with specified names in levels
+   *
+   * @param names the names of memory manager in levels
+   * @return the memory manager if find it, otherwise null
+   */
+  public MemoryManager getMemoryManager(String... names) {
+    return getMemoryManager(0, names);
+  }
+
+  /**
+   * Get the memory manager with specified names in levels
+   *
+   * @param index the index of names
+   * @param names the names of memory manager in levels
+   * @return the memory manager if find it, otherwise null
+   */
+  private MemoryManager getMemoryManager(int index, String... names) {
+    if (index >= names.length) {
+      return this;
+    }
+    MemoryManager memoryManager = children.get(names[index]);
+    if (memoryManager != null) {
+      return memoryManager.getMemoryManager(index + 1, names);
+    } else {
+      return null;
+    }
+  }
+
+  /**
+   * Release the child memory manager with specified name
+   *
+   * @param memoryManagerName the name of memory manager
+   */
+  public void releaseChildMemoryManager(String memoryManagerName) {
+    MemoryManager memoryManager = children.remove(memoryManagerName);
+    if (memoryManager != null) {
+      memoryManager.clearAll();
+      allocatedMemorySizeInBytes -= memoryManager.getTotalMemorySizeInBytes();
+    }
+  }
+
+  /** Clear all memory blocks and child memory managers */
+  public synchronized void clearAll() {
+    // release the child memory managers
+    for (MemoryManager child : children.values()) {
+      child.clearAll();
+    }
+    children.clear();
+    // release the memory blocks
+    for (IMemoryBlock block : allocatedMemoryBlocks.values()) {
+      if (block == null || block.isReleased()) {
+        continue;
+      }
+
+      block.markAsReleased();
+      allocatedMemorySizeInBytes -= block.getTotalMemorySizeInBytes();
+
+      try {
+        block.close();
+      } catch (Exception e) {
+        LOGGER.error("releaseWithOutNotify: failed to close memory block", e);
+      }
+    }
+    allocatedMemoryBlocks.clear();
+  }
+
+  // endregion
+
+  // region The Methods of Attribute
+
+  public String getName() {
+    return name;
+  }
+
+  public boolean isEnable() {
+    return enabled;
+  }
+
+  /** Get total memory size in bytes of memory manager */
+  public long getTotalMemorySizeInBytes() {
+    return totalMemorySizeInBytes;
+  }
+
+  public void setTotalMemorySizeInBytes(long totalMemorySizeInBytes) {
+    this.totalMemorySizeInBytes = totalMemorySizeInBytes;
+  }
+
+  public void setTotalMemorySizeInBytesWithReload(long totalMemorySizeInBytes) {
+    reAllocateMemoryAccordingToRatio((double) totalMemorySizeInBytes / this.totalMemorySizeInBytes);
+  }
+
+  /** Get available memory size in bytes of memory manager */
+  public long getAvailableMemorySizeInBytes() {
+    return totalMemorySizeInBytes - allocatedMemorySizeInBytes;
+  }
+
+  /** Get allocated memory size in bytes of memory manager */
+  public long getAllocatedMemorySizeInBytes() {
+    return allocatedMemorySizeInBytes;
+  }
+
+  /** Get actual used memory size in bytes of memory manager */
+  public long getUsedMemorySizeInBytes() {
+    long memorySize =
+        allocatedMemoryBlocks.values().stream().mapToLong(IMemoryBlock::getUsedMemoryInBytes).sum();
+    for (MemoryManager child : children.values()) {
+      memorySize += child.getUsedMemorySizeInBytes();
+    }
+    return memorySize;
+  }
+
+  // endregion
+
+  @Override
+  public String toString() {
+    return "MemoryManager{"
+        + "name="
+        + name
+        + ", enabled="
+        + enabled
+        + ", totalMemorySizeInBytes="
+        + totalMemorySizeInBytes
+        + ", allocatedMemorySizeInBytes="
+        + allocatedMemorySizeInBytes
+        + '}';
+  }
+
+  public void print() {
+    print(0);
+  }
+
+  private void print(int indent) {
+    StringBuilder sb = new StringBuilder();
+    for (int i = 0; i < indent; i++) {
+      sb.append("  ");
+    }
+    sb.append(this);
+    LOGGER.info(sb.toString());
+    for (IMemoryBlock block : allocatedMemoryBlocks.values()) {
+      block.print(indent + 2);
+    }
+    for (MemoryManager child : children.values()) {
+      child.print(indent + 1);
+    }
+  }
+}
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/ServiceType.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/ServiceType.java
index 205cbc4f6a4..7267c79a665 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/ServiceType.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/ServiceType.java
@@ -80,6 +80,7 @@ public enum ServiceType {
   PIPE_PLUGIN_CLASSLOADER_MANAGER_SERVICE(
       "Pipe Plugin Classloader Manager Service", "PipePluginClassLoader"),
   AINode_RPC_SERVICE("Rpc Service for AINode", "AINodeRPCService"),
+  MEMORY_RUNTIME_AGENT("Memory Runtime Agent", "MemoryRuntimeAgent"),
   PIPE_RUNTIME_DATA_NODE_AGENT("Pipe Runtime Data Node Agent", "PipeRuntimeDataNodeAgent"),
   PIPE_RUNTIME_CONFIG_NODE_AGENT("Pipe Runtime Config Node Agent", "PipeRuntimeConfigNodeAgent"),
   SUBSCRIPTION_RUNTIME_AGENT("Subscription Runtime Agent", "SubscriptionRuntimeAgent"),
diff --git a/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/memory/MemoryBlockTest.java b/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/memory/MemoryBlockTest.java
new file mode 100644
index 00000000000..dee41447aad
--- /dev/null
+++ b/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/memory/MemoryBlockTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.commons.memory;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MemoryBlockTest {
+
+  @Test
+  public void test() throws Exception {
+    IMemoryBlock memoryBlock1 = new AtomicLongMemoryBlock("Block1", null, 20);
+    IMemoryBlock memoryBlock2 =
+        new AtomicLongMemoryBlock("Block2", null, 100, MemoryBlockType.DYNAMIC);
+    // Test Attributes
+    Assert.assertEquals("Block1", memoryBlock1.getName());
+    Assert.assertEquals(0, memoryBlock1.getUsedMemoryInBytes());
+    Assert.assertEquals(20, memoryBlock1.getFreeMemoryInBytes());
+    Assert.assertEquals(20, memoryBlock1.getTotalMemorySizeInBytes());
+    Assert.assertEquals(MemoryBlockType.NONE, memoryBlock1.getMemoryBlockType());
+    Assert.assertFalse(memoryBlock1.isReleased());
+
+    Assert.assertEquals("Block2", memoryBlock2.getName());
+    Assert.assertEquals(0, memoryBlock2.getUsedMemoryInBytes());
+    Assert.assertEquals(100, memoryBlock2.getFreeMemoryInBytes());
+    Assert.assertEquals(100, memoryBlock2.getTotalMemorySizeInBytes());
+    Assert.assertEquals(MemoryBlockType.DYNAMIC, memoryBlock2.getMemoryBlockType());
+    Assert.assertFalse(memoryBlock2.isReleased());
+
+    // Test Allocation
+    Assert.assertTrue(memoryBlock1.allocate(10));
+    Assert.assertEquals(10, memoryBlock1.getUsedMemoryInBytes());
+    Assert.assertEquals(10, memoryBlock1.getFreeMemoryInBytes());
+    Assert.assertFalse(memoryBlock1.allocate(20));
+    Assert.assertEquals(10, memoryBlock1.getUsedMemoryInBytes());
+    Assert.assertEquals(10, memoryBlock1.getFreeMemoryInBytes());
+    Assert.assertFalse(memoryBlock1.allocateIfSufficient(10, 0.5));
+    Assert.assertEquals(0, memoryBlock1.release(10));
+    Assert.assertEquals(0, memoryBlock1.getUsedMemoryInBytes());
+    Assert.assertEquals(20, memoryBlock1.getFreeMemoryInBytes());
+    Assert.assertTrue(memoryBlock1.allocateIfSufficient(10, 0.5));
+    Assert.assertEquals(10, memoryBlock1.getUsedMemoryInBytes());
+    Assert.assertEquals(10, memoryBlock1.getFreeMemoryInBytes());
+
+    memoryBlock2.markAsReleased();
+    Assert.assertTrue(memoryBlock2.isReleased());
+
+    memoryBlock1.close();
+    memoryBlock2.close();
+  }
+}
diff --git a/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/memory/MemoryManagerTest.java b/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/memory/MemoryManagerTest.java
new file mode 100644
index 00000000000..a46f75ffc04
--- /dev/null
+++ b/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/memory/MemoryManagerTest.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.commons.memory;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class MemoryManagerTest {
+  private final MemoryManager GLOBAL_MEMORY_MANAGER = MemoryConfig.global();
+
+  @Before
+  public void reset() {
+    GLOBAL_MEMORY_MANAGER.clearAll();
+    GLOBAL_MEMORY_MANAGER.setTotalMemorySizeInBytes(100);
+  }
+
+  @Test
+  public void testAttributes() {
+    Assert.assertEquals("GlobalMemoryManager", GLOBAL_MEMORY_MANAGER.getName());
+    Assert.assertFalse(GLOBAL_MEMORY_MANAGER.isEnable());
+    Assert.assertEquals(100, GLOBAL_MEMORY_MANAGER.getTotalMemorySizeInBytes());
+    Assert.assertEquals(100, GLOBAL_MEMORY_MANAGER.getAvailableMemorySizeInBytes());
+    Assert.assertEquals(0, GLOBAL_MEMORY_MANAGER.getAllocatedMemorySizeInBytes());
+    Assert.assertEquals(0, GLOBAL_MEMORY_MANAGER.getUsedMemorySizeInBytes());
+  }
+
+  @Test
+  public void testAllocate() throws InterruptedException {
+    Assert.assertEquals("GlobalMemoryManager", GLOBAL_MEMORY_MANAGER.getName());
+    Assert.assertFalse(GLOBAL_MEMORY_MANAGER.isEnable());
+    Assert.assertEquals(100, GLOBAL_MEMORY_MANAGER.getTotalMemorySizeInBytes());
+
+    // create memoryBlock1 in the size of 20 from globalMemoryManager
+    IMemoryBlock memoryBlock1 =
+        GLOBAL_MEMORY_MANAGER.exactAllocate("Block1", 20, MemoryBlockType.STATIC);
+    Assert.assertEquals(80, GLOBAL_MEMORY_MANAGER.getAvailableMemorySizeInBytes());
+    Assert.assertEquals(20, GLOBAL_MEMORY_MANAGER.getAllocatedMemorySizeInBytes());
+    Assert.assertEquals("Block1", memoryBlock1.getName());
+    Assert.assertEquals(20, memoryBlock1.getTotalMemorySizeInBytes());
+    Assert.assertEquals(MemoryBlockType.STATIC, memoryBlock1.getMemoryBlockType());
+
+    // create memoryBlock2 in the size of 10 from globalMemoryManager
+    IMemoryBlock memoryBlock2 =
+        GLOBAL_MEMORY_MANAGER.exactAllocateIfSufficient(
+            "Block2", 10, 0.9f, MemoryBlockType.DYNAMIC);
+    Assert.assertEquals(70, GLOBAL_MEMORY_MANAGER.getAvailableMemorySizeInBytes());
+    Assert.assertEquals(30, GLOBAL_MEMORY_MANAGER.getAllocatedMemorySizeInBytes());
+    Assert.assertEquals("Block2", memoryBlock2.getName());
+    Assert.assertEquals(10, memoryBlock2.getTotalMemorySizeInBytes());
+    Assert.assertEquals(MemoryBlockType.DYNAMIC, memoryBlock2.getMemoryBlockType());
+
+    // create subMemoryManager in the size of 50 from globalMemoryManager
+    MemoryManager subMemoryManager =
+        GLOBAL_MEMORY_MANAGER.getOrCreateMemoryManager("SubManager", 50, true);
+    Assert.assertEquals(20, GLOBAL_MEMORY_MANAGER.getAvailableMemorySizeInBytes());
+    Assert.assertEquals(80, GLOBAL_MEMORY_MANAGER.getAllocatedMemorySizeInBytes());
+    Assert.assertEquals(50, subMemoryManager.getTotalMemorySizeInBytes());
+
+    // create memoryBlock3 in the size of 20 from globalMemoryManager
+    IMemoryBlock memoryBlock3 = GLOBAL_MEMORY_MANAGER.exactAllocate("Block3", MemoryBlockType.NONE);
+    Assert.assertEquals(0, GLOBAL_MEMORY_MANAGER.getAvailableMemorySizeInBytes());
+    Assert.assertEquals(100, GLOBAL_MEMORY_MANAGER.getAllocatedMemorySizeInBytes());
+    Assert.assertEquals("Block3", memoryBlock3.getName());
+    Assert.assertEquals(20, memoryBlock3.getTotalMemorySizeInBytes());
+    Assert.assertEquals(MemoryBlockType.NONE, memoryBlock3.getMemoryBlockType());
+
+    // create memoryBlock4 in the size of 50 from subMemoryManager
+    IMemoryBlock memoryBlock4 =
+        subMemoryManager.tryAllocate("Block4", 100, size -> size / 2, MemoryBlockType.STATIC);
+    Assert.assertEquals(0, GLOBAL_MEMORY_MANAGER.getAvailableMemorySizeInBytes());
+    Assert.assertEquals("Block4", memoryBlock4.getName());
+    Assert.assertEquals(50, memoryBlock4.getTotalMemorySizeInBytes());
+    Assert.assertEquals(MemoryBlockType.STATIC, memoryBlock4.getMemoryBlockType());
+
+    Assert.assertEquals(0, GLOBAL_MEMORY_MANAGER.getUsedMemorySizeInBytes());
+
+    // allocate memory
+    Assert.assertTrue(memoryBlock1.allocate(5));
+    Assert.assertFalse(memoryBlock1.allocate(100));
+    Assert.assertEquals(5, memoryBlock1.getUsedMemoryInBytes());
+    Assert.assertEquals(5, GLOBAL_MEMORY_MANAGER.getUsedMemorySizeInBytes());
+    Assert.assertTrue(memoryBlock2.allocateUntilAvailable(10, 100));
+    Assert.assertEquals(10, memoryBlock2.getUsedMemoryInBytes());
+    Assert.assertEquals(15, GLOBAL_MEMORY_MANAGER.getUsedMemorySizeInBytes());
+    Assert.assertTrue(memoryBlock3.allocate(15));
+    Assert.assertEquals(15, memoryBlock3.getUsedMemoryInBytes());
+    Assert.assertEquals(30, GLOBAL_MEMORY_MANAGER.getUsedMemorySizeInBytes());
+    Assert.assertTrue(memoryBlock4.allocate(40));
+    Assert.assertEquals(40, memoryBlock4.getUsedMemoryInBytes());
+    Assert.assertEquals(40, subMemoryManager.getUsedMemorySizeInBytes());
+    Assert.assertEquals(70, GLOBAL_MEMORY_MANAGER.getUsedMemorySizeInBytes());
+
+    // release memory
+    memoryBlock1.release(100);
+    Assert.assertEquals(0, memoryBlock1.getUsedMemoryInBytes());
+    Assert.assertEquals(65, GLOBAL_MEMORY_MANAGER.getUsedMemorySizeInBytes());
+    memoryBlock2.release(10);
+    Assert.assertEquals(0, memoryBlock2.getUsedMemoryInBytes());
+    Assert.assertEquals(55, GLOBAL_MEMORY_MANAGER.getUsedMemorySizeInBytes());
+    memoryBlock3.release(10);
+    Assert.assertEquals(5, memoryBlock3.getUsedMemoryInBytes());
+    Assert.assertEquals(45, GLOBAL_MEMORY_MANAGER.getUsedMemorySizeInBytes());
+    memoryBlock4.release(1);
+    Assert.assertEquals(39, memoryBlock4.getUsedMemoryInBytes());
+    Assert.assertEquals(39, subMemoryManager.getUsedMemorySizeInBytes());
+    Assert.assertEquals(44, GLOBAL_MEMORY_MANAGER.getUsedMemorySizeInBytes());
+
+    // release memoryBlock3
+    GLOBAL_MEMORY_MANAGER.release(memoryBlock3);
+    Assert.assertEquals(20, GLOBAL_MEMORY_MANAGER.getAvailableMemorySizeInBytes());
+    // release memoryBlock4
+    subMemoryManager.release(memoryBlock4);
+    Assert.assertEquals(50, subMemoryManager.getAvailableMemorySizeInBytes());
+    Assert.assertNull(subMemoryManager.getOrCreateMemoryManager("SubManager2", 100));
+
+    MemoryManager subMemoryManager2 = subMemoryManager.getOrCreateMemoryManager("SubManager2", 20);
+    Assert.assertFalse(subMemoryManager2.isEnable());
+    Assert.assertEquals(20, subMemoryManager2.getTotalMemorySizeInBytes());
+    Assert.assertEquals(30, subMemoryManager.getAvailableMemorySizeInBytes());
+
+    Assert.assertNull(GLOBAL_MEMORY_MANAGER.getMemoryManager("123"));
+    Assert.assertEquals(subMemoryManager, GLOBAL_MEMORY_MANAGER.getMemoryManager("SubManager"));
+    Assert.assertEquals(subMemoryManager2, subMemoryManager.getMemoryManager("SubManager2"));
+    Assert.assertEquals(
+        subMemoryManager2, GLOBAL_MEMORY_MANAGER.getMemoryManager("SubManager", "SubManager2"));
+
+    // create memoryBlock when enable
+    IMemoryBlock memoryBlock5 =
+        subMemoryManager.exactAllocate("Block5", 10, MemoryBlockType.DYNAMIC);
+    Assert.assertEquals(10, memoryBlock5.getTotalMemorySizeInBytes());
+    Assert.assertEquals(20, subMemoryManager.getAvailableMemorySizeInBytes());
+    Assert.assertNull(
+        subMemoryManager.exactAllocateIfSufficient("Block6", 5, 0.6f, MemoryBlockType.STATIC));
+    IMemoryBlock memoryBlock6 =
+        subMemoryManager.exactAllocateIfSufficient("Block6", 5, 0.8f, MemoryBlockType.DYNAMIC);
+    Assert.assertEquals(5, memoryBlock6.getTotalMemorySizeInBytes());
+    Assert.assertEquals(15, subMemoryManager.getAvailableMemorySizeInBytes());
+    IMemoryBlock memoryBlock7 =
+        subMemoryManager2.tryAllocate("Block7", 5, size -> size / 2, MemoryBlockType.STATIC);
+    Assert.assertEquals(5, memoryBlock7.getTotalMemorySizeInBytes());
+    Assert.assertEquals(15, subMemoryManager2.getAvailableMemorySizeInBytes());
+
+    // release subMemoryManager
+    GLOBAL_MEMORY_MANAGER.releaseChildMemoryManager("SubManager");
+    Assert.assertEquals(70, GLOBAL_MEMORY_MANAGER.getAvailableMemorySizeInBytes());
+    Assert.assertFalse(memoryBlock1.isReleased());
+    Assert.assertFalse(memoryBlock2.isReleased());
+    Assert.assertTrue(memoryBlock3.isReleased());
+    Assert.assertTrue(memoryBlock4.isReleased());
+    Assert.assertTrue(memoryBlock5.isReleased());
+    Assert.assertTrue(memoryBlock6.isReleased());
+    Assert.assertTrue(memoryBlock7.isReleased());
+  }
+}