Quantcast
Channel: SCN : Unanswered Discussions - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 4343

Queries for Used and Resident memory and comparison with Overview tab numbers

$
0
0

Hi,

 

I look at the overview tab of the HANA studio for DB used memory and DB resident memory.

 

When I use the queries 1 ,2 and unix command below, the results match with the numbers displayed in the overview tab.

 

SQL Query 1 for DB used memory: (Available in HANA documents)

SELECT ROUND(SUM(TOTAL_MEMORY_USED_SIZE/1024/1024/1024), 2) AS
"Used Memory GB" FROM SYS.M_SERVICE_MEMORY;

 

SQL Query 2 for DB Resident memory: (I created this by observing the table contents)

SELECT ROUND(SUM(PHYSICAL_MEMORY_SIZE/1024/1024/1024), 2) AS
"DB RESIDENT Memory GB" FROM SYS.M_SERVICE_MEMORY;

 

Unix command: Provides same value as SQL query 2.

cat `ps h -U qp4adm -o "/proc/%p/status" | tr -d ' '` | awk '/VmSize/ {v+=$2} /VmPeak/ {vp+=$2} /VmRSS/ {r+=$2;} /VmHWM/ {rp+=$2} END {printf("Virtual Size = %.2f GB (peak = %.2f), Resident size = %.2f GB (peak = %.2f)\n", v/1024/1024, vp/1024/1024, r/1024/1024, rp/1024/1024)}'

 

My Questions:

 

Question 1:Now when I use the query 3 below(just getting the above 2 together with the process name), I observe that used memory is more than the resident memory for some services.

I believe that this is wrong based on the below explanation which is in the official HANA docs.

 

Can anybody in this forum throw more light on this observation?

 

SQL Query 3:

SELECT SERVICE_NAME,ROUND(SUM(TOTAL_MEMORY_USED_SIZE/1024/1024/1024), 2) AS
"Used Memory GB", ROUND(SUM(PHYSICAL_MEMORY_SIZE/1024/1024/1024), 2) AS
"DB RESIDENT Memory GB" FROM SYS.M_SERVICE_MEMORY GROUP BY SERVICE_NAME

 

Explanation on Resident from HANA doc:

"

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.

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, 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."

 

Question 2:

SQL Query 5: This query doesn't match with the resident memory value in overview tab. Should it? I mean if it doesn't then is it an issue in the studio?

 

SELECT ROUND((USED_PHYSICAL_MEMORY + FREE_PHYSICAL_MEMORY)/1024/1024/1024, 2) AS "Physical Memory GB", ROUND(USED_PHYSICAL_MEMORY/1024/1024/1024, 2) AS "Resident GB" FROM PUBLIC.M_HOST_RESOURCE_UTILIZATION

 

Question 3:

 

In some Studios(meaning different versions) I have used the result of SQL query 1 doesn't match with the studio number. Can we consider this as an issue in the studio?

 

Question 4:

 

From the explanation above, can we understand that the Resident size increases since the freed memory is not released to the OS but to the HANA memory pool?

How do we differentiate between DB used and DB Resident memory?

The definition for both are same-> Physical memory in use by the process.

 

Used memory=" Code+stack+HANA memory pool(Tables,temporary computations)

Resident memory=?

 

Regards,

Sandeep


Viewing all articles
Browse latest Browse all 4343

Trending Articles