一言で言うと、Database Resident Memory は HANA のプロセスが使っている物理メモリサイズで、HANA Used Memory は HANA から見て論理的に使っているメモリサイズ。つまり、Database Resident Memory - HANA Used Memory の差分はOSから見ると物理メモリを使っているけど、HANA から見ると空きメモリで利用可能な領域ということだと思う。
When memory is required for table growth or for temporary computations, the SAP HANA code obtains it from the existing memory pool. When the pool cannot satisfy the request, the HANA memory manager will request and reserve more memory from the operating system. At this point, the virtual memory size of the HANA processes grows.
https://www.edge-solutions.com/wp-content/uploads/2014/03/HANA_Memory_Usage_v2.pdf
Once a temporary computation completes or a table is dropped, the freed memory is returned to the memory manager, who recycles it to its pool, usually without informing Linux. Thus, from SAP HANA’s perspective, the amount of Used Memory shrinks, but the process’ virtual and resident sizes are not affected. This creates a situation where the Used Memory may even shrink to below the size of SAP HANA’s resident memory, which is perfectly normal.
The following illustration shows the relationship between physical memory, Linux virtual and resident memory, and SAP HANA’s pool and Used Memory indicators. Note how changes in Used Memory do not affect the processes’ virtual and resident sizes.
以下のスライドで説明すると HANA Used Memory = Code and Stack + Table Data + Database Management で Allocated Memory Pool は含まない。Database Resident Memory > HANA Used Memory となる状況では、再利用可能な Allocated Memory Pool (Free) をプロセスが物理メモリを解放せずにそのままにしている(必要になったら上書き再利用する)と思われる。
Database Resident Memory の情報ソースは
https://gerardnico.com/wiki/hana/memory/resident_memory3.1 - Hana Studio
3.1.1 - Database Resident
For the SAP Hana process:
SELECT round(SUM(PHYSICAL_MEMORY_SIZE)/1024/1024/1024,2) AS "Database Resident Memory (Gb)" FROM M_SERVICE_MEMORY
M_SERVICE_MEMORY システムビューの PHYSICAL_MEMORY_SIZE の合計で、
SAP Help PortalM_SERVICE_MEMORY System View
Detailed information on memory utilization by services.
Structure
Column name Data type Unit Description PHYSICAL_MEMORY_SIZE BIGINT Byte Physical/resident memory size (operating system perspective)
このシステムビューはおそらく /proc/[PID]/smaps などからプロセスが使用しているメモリサイズを取得しているのではないかと思う。
/proc/[pid]/smaps (since Linux 2.6.14)
This file shows memory consumption for each of the process's
mappings. (The pmap(1) command displays similar information,
in a form that may be easier for parsing.) For each mapping
there is a series of lines such as the following:00400000-0048a000 r-xp 00000000 fd:03 960637 /bin/bash Size: 552 kB Rss:460 kB Pss:100 kB Shared_Clean: 452 kB Shared_Dirty: 0 kB Private_Clean: 8 kB Private_Dirty: 0 kB Referenced: 460 kB Anonymous: 0 kB AnonHugePages: 0 kB ShmemHugePages: 0 kB ShmemPmdMapped: 0 kB Swap: 0 kB KernelPageSize: 4 kB MMUPageSize: 4 kB KernelPageSize: 4 kB MMUPageSize: 4 kB Locked: 0 kB ProtectionKey: 0 VmFlags: rd ex mr mw me dwThe first of these lines shows the same information as is
proc(5) - Linux manual page
displayed for the mapping in /proc/[pid]/maps. The following
lines show the size of the mapping, the amount of the mapping
that is currently resident in RAM ("Rss"), the process's
proportional share of this mapping ("Pss"), the number of
clean and dirty shared pages in the mapping, and the number of
clean and dirty private pages in the mapping.