OceanBase Database allows you to view the memory usage in logs.
Tenant statistics
The following example shows the statistics of the total memory usage of tenants. Each row shows the memory usage information of a tenant.
[2021-09-09 17:13:17.232782] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=5] [dc=0] [MEMORY] tenant: 501, limit: 1,073,741,824 hold: 2,097,152 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[2021-09-09 17:13:17.232962] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=5] [dc=0] [MEMORY] tenant: 502, limit: 1,073,741,824 hold: 4,194,304 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[2021-09-09 17:13:17.233133] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=5] [dc=0] [MEMORY] tenant: 503, limit: 1,073,741,824 hold: 2,097,152 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[2021-09-09 17:13:17.233308] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=5] [dc=0] [MEMORY] tenant: 504, limit: 1,073,741,824 hold: 8,388,608 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[2021-09-09 17:13:17.233485] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=5] [dc=0] [MEMORY] tenant: 505, limit: 1,073,741,824 hold: 2,097,152 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[2021-09-09 17:13:17.233659] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=5] [dc=0] [MEMORY] tenant: 506, limit: 4,294,967,296 hold: 2,097,152 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[2021-09-09 17:13:17.233832] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=5] [dc=0] [MEMORY] tenant: 507, limit: 1,073,741,824 hold: 2,097,152 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[2021-09-09 17:13:17.234014] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=5] [dc=0] [MEMORY] tenant: 508, limit: 1,073,741,824 hold: 6,291,456 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[2021-09-09 17:13:17.234187] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=4] [dc=0] [MEMORY] tenant: 509, limit: 1,073,741,824 hold: 2,097,152 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[2021-09-09 17:13:17.234358] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=5] [dc=0] [MEMORY] tenant: 510, limit: 2,147,483,648 hold: 2,097,152 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[2021-09-09 17:13:17.234532] INFO [LIB] ob_malloc_allocator.cpp:505 [43566][0][Y0-0000000000000000-0-0] [lt=5] [dc=0] [MEMORY] tenant: 512, limit: 1,073,741,824 hold: 2,097,152 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
Statistics of tenant contexts
A context is a coarse-grained memory unit. A tenant can have multiple contexts. The following example shows the memory usage statistics of contexts in a tenant:
[MEMORY] ctx_id= DEFAULT_CTX_ID hold_bytes= 534,773,760
[MEMORY] ctx_id= MEMSTORE_CTX_ID hold_bytes= 123,731,968
[MEMORY] ctx_id= TRANS_CTX_MGR_ID hold_bytes= 12,582,912
[MEMORY] ctx_id= REPLAY_STATUS_CTX_ID hold_bytes= 20,971,520
[MEMORY] ctx_id= PLAN_CACHE_CTX_ID hold_bytes= 14,680,064
[MEMORY] ctx_id= WORK_AREA hold_bytes= 2,097,152
Statistics of modules in a tenant context
A module (mod) is a fine-grained memory unit. A context can have multiple mods. The following example shows the memory usage statistics of mods in a tenant context:
[MEMORY] tenant_id= 1 ctx_id= DEFAULT_CTX_ID hold= 534,773,760 used= 431,805,528
[MEMORY] hold= 142,591,488 used= 140,579,840 count= 30 avg_used= 4,685,994 mod=MysqlRequesReco
[MEMORY] hold= 125,798,400 used= 125,767,680 count= 60 avg_used= 2,096,128 mod=SqlExecutor
[MEMORY] hold= 104,857,600 used= 104,855,040 count= 1 avg_used= 104,855,040 mod=TransAudit
[MEMORY] hold= 23,867,392 used= 19,660,800 count= 14 avg_used= 1,404,342 mod=LOCALDEVICE
[MEMORY] hold= 12,579,840 used= 12,576,768 count= 6 avg_used= 2,096,128 mod=PartitLogServic
[MEMORY] hold= 10,483,200 used= 10,480,640 count= 5 avg_used= 2,096,128 mod=Election
[MEMORY] hold= 4,496,000 used= 4,483,464 count= 67 avg_used= 66,917 mod=ResultSet
[MEMORY] hold= 4,193,280 used= 4,192,256 count= 2 avg_used= 2,096,128 mod=OB_KVSTORE_CACHE
[MEMORY] hold= 2,154,368 used= 408,600 count= 24,952 avg_used= 16 mod=Number
[MEMORY] hold= 2,096,640 used= 2,096,128 count= 1 avg_used= 2,096,128 mod=ElectionGroup
[MEMORY] hold= 1,700,736 used= 1,687,552 count= 206 avg_used= 8,192 mod=MemtableCallbac
PM statistics in a tenant
Provisional memory (PM) is used for SQL execution and is released at the end of an SQL execution. The following example shows the PM statistics:
[MEMORY][PM] tid= 48768 used= 0 hold= 2,097,152 pm=0x7f4e3066eec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= 48770 used= 2,096,192 hold= 2,097,152 pm=0x7f4e3005aec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= 48771 used= 2,161,792 hold= 4,194,304 pm=0x7f4e2fd50ec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= 48772 used= 124,691,512 hold= 127,926,272 pm=0x7f4e2fa46ec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= 48773 used= 0 hold= 4,194,304 pm=0x7f4e2f73cec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= 48774 used= 0 hold= 2,097,152 pm=0x7f4e2f432ec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= 48775 used= 0 hold= 2,097,152 pm=0x7f4e2f128ec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= 48776 used= 0 hold= 2,097,152 pm=0x7f4e2ee1eec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= 48777 used= 0 hold= 2,097,152 pm=0x7f4e2eb14ec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= 48780 used= 0 hold= 2,097,152 pm=0x7f4e2dff6ec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= 48784 used= 0 hold= 2,097,152 pm=0x7f4e2d3ceec0 ctx_name=DEFAULT_CTX_ID
[MEMORY][PM] tid= summary used= 128,949,496 hold= 153,092,096