Skip to main content
Version: Stable-3.1

Memory Management

This section briefly introduces memory classification and StarRocks’ methods of managing memory.

Memory Classification

Explanation:

MetricNameDescription
processTotal memory used of BE
query_poolMemory used by data queryingConsists of two parts: memory used by the execution layer and memory used by the storage layer.
loadMemory used by data loadingGenerally MemTable
table_metaMetadata memoryS Schema, Tablet metadata, RowSet metadata, Column metadata, ColumnReader, IndexReader
compactionMulti-version memory compactioncompaction that happens after data import is complete
snapshotSnapshot memoryGenerally used for clone, little memory usage
column_poolColumn pool memoryRequest to release column cache for accelerated column
page_cacheBE's own PageCacheThe default is off, the user can turn it on by modifying the BE file
  • BE Configuration
NameDefaultDescription
vector_chunk_size4096Number of chunk rows
mem_limit90%BE process memory upper limit. You can set it as a percentage ("80%") or a physical limit ("100G"). The default hard limit is 90% of the server's memory size, and the soft limit is 80%. You need to configure this parameter if you want to deploy StarRocks with other memory-intensive services on a same server.
disable_storage_page_cachefalseThe boolean value to control whether to disable PageCache. When PageCache is enabled, StarRocks caches the recently scanned data. PageCache can significantly improve the query performance when similar queries are repeated frequently. true indicates to disable PageCache. Use this item together with storage_page_cache_limit, you can accelerate query performance in scenarios with sufficient memory resources and much data scan. The default value of this item has been changed from true to false since StarRocks v2.4.
write_buffer_size104857600The capacity limit of a single MemTable, exceeding which a disk swipe will be performed.
load_process_max_memory_limit_bytes107374182400The upper limit of memory resources that can be taken up by all load processes on a BE node. Its value is the smaller one between mem_limit * load_process_max_memory_limit_percent / 100 and load_process_max_memory_limit_bytes. If this threshold is exceeded, a flush and backpressure will be triggered.
load_process_max_memory_limit_percent30The maximum percentage of memory resources that can be taken up by all load processes on a BE node. Its value is the smaller one between mem_limit * load_process_max_memory_limit_percent / 100 and load_process_max_memory_limit_bytes. If this threshold is exceeded, a flush and backpressure will be triggered.
default_load_mem_limit2147483648If the memory limit on the receiving side is reached for a single import instance, a disk swipe will be triggered. This needs to be modified with the Session variable load_mem_limit to take effect.
max_compaction_concurrency-1The maximum concurrency of compactions (both Base Compaction and Cumulative Compaction). The value -1 indicates that no limit is imposed on the concurrency.
cumulative_compaction_check_interval_seconds1Interval of compaction check
  • Session variables
NameDefaultDescription
query_mem_limit0Memory limit of a query on each BE node
load_mem_limit0Memory limit of a single import task. If the value is 0, exec_mem_limit will be taken

View memory usage

  • mem_tracker
//View the overall memory statistics
<http://be_ip:be_http_port/mem_tracker>

// View fine-grained memory statistics
<http://be_ip:be_http_port/mem_tracker?type=query_pool&upper_level=3>
  • tcmalloc
<http://be_ip:be_http_port/memz>
------------------------------------------------
MALLOC: 777276768 ( 741.3 MiB) Bytes in use by application
MALLOC: + 8851890176 ( 8441.8 MiB) Bytes in page heap freelist
MALLOC: + 143722232 ( 137.1 MiB) Bytes in central cache freelist
MALLOC: + 21869824 ( 20.9 MiB) Bytes in transfer cache freelist
MALLOC: + 832509608 ( 793.9 MiB) Bytes in thread cache freelists
MALLOC: + 58195968 ( 55.5 MiB) Bytes in malloc metadata
MALLOC: ------------
MALLOC: = 10685464576 (10190.5 MiB) Actual memory used (physical + swap)
MALLOC: + 25231564800 (24062.7 MiB) Bytes released to OS (aka unmapped)
MALLOC: ------------
MALLOC: = 35917029376 (34253.1 MiB) Virtual address space used
MALLOC:
MALLOC: 112388 Spans in use
MALLOC: 335 Thread heaps in use
MALLOC: 8192 Tcmalloc page size
------------------------------------------------
Call ReleaseFreeMemory() to release freelist memory to the OS (via madvise()).
Bytes released to the OS take up virtual address space but no physical memory.

The memory queried by this method is accurate. However, some memory in StarRocks is reserved but not in use. TcMalloc counts the memory that is reserved, not the memory used.

Here Bytes in use by application refers to the memory currently in use.

  • metrics
curl -XGET http://be_ip:be_http_port/metrics | grep 'mem'
curl -XGET http://be_ip:be_http_port/metrics | grep 'column_pool'

The value of metrics is updated every 10 seconds. It is possible to monitor some of the memory statistics with older versions.