SAP Hana - Memory

About

When SAP HANA starts up, the OS reserves memory for

  • the program code (sometimes called the text),
  • the program stack,
  • and static data.

It then dynamically reserves additional data memory upon requests from the SAP HANA memory manager.

Sap Hana Memory

It is theoretically possible that the memory manager will still face a need for more memory that it cannot satisfy. For instance, when too many concurrent transactions use up all memory, or when a particularly complex query performs a cross-join on very large tables, creating a huge intermediate result that exceed the available memory. Such situations can even lead to an Out Of Memory failure.

On most SAP HANA hosts, physical memory ranges from 256 Gigabytes (GB) to multiple Terabytes (TB).

Indicators

It is important to understand the behavior of used memory over time and under peak loads. Most important indicators are used memory and peak used memory

Over time / Memory relationship

Since SAP HANA contains its own memory manager and memory pool, external indicators such as:

  • the size of resident memory at host level
  • and the size of virtual and resident memory at process level

can be misleading when you are estimating the real memory requirements of an SAP HANA deployment.

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 the OS. Thus, from SAP HANA’s perspective, the amount of Used Memory shrinks, but the process’ virtual and resident sizes are not affected.

Sap Hana Memory Relationship

Monitoring

See:

select 
	  service_name as "service_name"
	, round(logical_memory_size/1024/1024/1024,2) as "logical_memory_size Gb"
	, round(physical_memory_size/1024/1024/1024,2) as "physical_memory_size Gb"
	, round(code_size/1024/1024/1024,2) as "code_size Gb"
	, round(stack_size/1024/1024/1024,2) as "stack_size Gb"
	, round(heap_memory_allocated_size/1024/1024/1024,2) as "heap_memory_allocated_size Gb"
	, round(heap_memory_used_size/1024/1024/1024,2) as "heap_memory_used_size Gb"
	, round(shared_memory_allocated_size/1024/1024/1024,2) as "shared_memory_allocated_size Gb"
	, round(shared_memory_used_size/1024/1024/1024,2) as "shared_memory_used_size Gb"
	, round(compactors_allocated_size/1024/1024/1024,2) as "compactors_allocated_size Gb"
	, round(compactors_freeable_size/1024/1024/1024,2) as "compactors_freeable_size Gb"
	, round(allocation_limit/1024/1024/1024,2) as "allocation_limit Gb"
	, round(effective_allocation_limit/1024/1024/1024,2) as "effective_allocation_limit Gb"
	, round(total_memory_used_size/1024/1024/1024,2) as "total_memory_used_size Gb"
from M_SERVICE_MEMORY

Output example:

service name logical memory size Gb physical memory size Gb code size Gb stack size Gb heap memory allocated size Gb heap memory used size Gb shared memory allocated size Gb shared memory used size Gb compactors allocated size Gb compactors freeable size Gb allocation limit Gb effective allocation limit Gb
nameserver 3.99 1.31 1.72 0.08 1.89 0.87 0.13 0.02 0.07 0 22.46 13.41
preprocessor 2.76 0.42 1.45 0.03 1 0.19 0 0 0 0 22.46 12.21
indexserver 10.83 7.64 1.77 0.17 8.4 5.96 0.41 0.14 1.37 0.41 22.46 18.71
scriptserver 4.07 1.16 1.73 0.09 1.96 1.01 0.13 0.02 0.07 0 22.46 13.45
webdispatcher 3.04 0.63 1.44 0.03 1.29 0.45 0 0 0 0 22.46 12.47
xsengine 4.55 1.4 1.73 0.09 2.44 1.38 0.13 0.02 0.07 0 22.46 13.82
compileserver 2.92 0.58 1.44 0.03 1.18 0.23 0 0 0 0 22.46 12.24
dpserver 4.28 1.35 1.75 0.09 2.16 1.03 0.13 0.02 0.07 0 22.46 13.49

Documentation / Reference

Task Runner