Memory Management in SAP Hana 2
Memory Management in SAP Hana 2
Memory Management in SAP Hana 2
0
Memory Usage in the SAP HANA Database
SAP HANA comprises of different processes that store the memory from the
operating system when you begin with the SAP HANA System. The SAP needs to
manage and follow its own memory during the running and operational mode of
the databases. However, it needs to be noted that you can only use one portion
of the requested memory at any time.
Memory is a fundamental resource of the SAP HANA database. Understanding
how the SAP HANA database requests, uses, and manages this resource is crucial
to the understanding of SAP HANA.
SAP HANA provides a variety of memory usage indicators that allow for
monitoring, tracking, and alerting.
The most important indicators are used memory and peak used memory.
You can find detailed information about memory consumption of individual
components and operations by looking into memory allocator statistics.
For more information about memory consumption with regards to SAP HANA
licenses, see SAP Note 1704499 System Measurement for License Audit.
The pre-reserved memory is made of various pools that are categorized into two
parts-
Used Memory
Resident Memory
SAP HANA Used Memory
The total amount of memory used by SAP HANA is referred to as used memory. It
includes program code and stack, all data and system tables, and the memory
required for temporary computations.
SAP HANA consists of a number of processes running in the Linux operating
environment. Under Linux, the operating system (OS) is responsible for reserving
memory to all processes. 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 when requested by
the SAP HANA memory manager. Dynamically allocated memory consists of heap
memory and shared memory.
The following figure shows used memory, consisting of code, stack, and table
data:
Since the code and program stack size are about 6 GB, almost all of used
memory is used for table storage, computations, and database management.
-- The following script shows peak used memory for entire sap hana system
-- top peak memory
select HOST,
round(INSTANCE_TOTAL_MEMORY_PEAK_USED_SIZE/(1024*1024*1024), 2) as
"Peak Used Memory GB"
from M_HOST_RESOURCE_UTILIZATION;
In order to point out the last greatest memory usage, get the first few top peak
memory usage size occurrences since the system start up. You will be able to
cross check peak memory usage with known date events such as batch
execution or data load into the database.
-- Get the 10 top peak used memory details
-- Result is sorted by memory size. ( it is not a sequential date and time list )
select top 30 HOST,
SERVER_TIMESTAMP,
round(INSTANCE_TOTAL_MEMORY_USED_SIZE/(1024*1024*1024), 2) as
"Used Memory GB"
from _SYS_STATISTICS.HOST_RESOURCE_UTILIZATION_STATISTICS
where hour(SERVER_TIMESTAMP) = 7 and minute(SERVER_TIMESTAMP) = 0
order by INSTANCE_TOTAL_MEMORY_USED_SIZE;
You can check SAP HANA peak used memory occurrences between 2 dates, this
is when your are requested to investigate memory usage during a specific period
of time. The previous script gives you different peak memory usage dates from
which you can investigate further.
This following Query would be very useful in the following context: Specific Peak
used memory event dates have been found and you would like to drill down the
events between 2 dates. You want to be able to bring up into a report how fast
memory usage has been occurring between specific date and time. The following
SQL result will show peak memory usage chronologically.
--
-- result is sorted by date and time
--
do begin
select
HOST,
TO_NVARCHAR(SERVER_TIMESTAMP,'YYYY-MM-DD HH24:MI:SS') as
DateAndTime,
RTRIM(round(INSTANCE_TOTAL_MEMORY_USED_SIZE/1024/1024/1024),0)
as "Peak Memory GB",
case
when round(INSTANCE_TOTAL_MEMORY_USED_SIZE/1024/1024/1024)
> :PERSONNAL_INDICATION_LIMIT then
'<---- '||
round(((INSTANCE_TOTAL_MEMORY_USED_SIZE/1024/1024/1024)/:TOTAL_HANA_
MEMORY_LIMIT)*100) || '% used.'
else
''
end WatchOut
from _SYS_STATISTICS.HOST_RESOURCE_UTILIZATION_STATISTICS
where SERVER_TIMESTAMP between :FROMSDATETIME and :TOSDATETIME
and round(INSTANCE_TOTAL_MEMORY_USED_SIZE/1024/1024/1024)
> :FILTER_DATA_FROM_PEAKMEMORY
order by "SERVER_TIMESTAMP" asc;
end;
When part of the virtually allocated memory actually needs to be used, it’s
loaded or mapped to the real, physical memory of the host and
becomes resident. Physical memory is the DRAM memory installed on the host.
Here is a SQL script which will give the top peak memory usage size since the
sap hana
Database Resident is the size of resident memory at operating system
level owing to SAP HANA database processes. In case of a MDC system,
Database Resident shows the memory allocated by the tenant database or
the system database;
Total Resident is the total size of resident memory in the operating
system, including other programs;
Physical Memory is the total physical memory available in the server.
SAP NOTE
3211034