Question

For one of our SQL Server, we recently add more memory. The initial value was 12GB. The server experienced a lack of physical memory so we added another 12GB, for a total of 24GB. Then I have set the followings values : min. server memory 1024MB - max server memory : 19456. Well everything is running fine, but I have few questions about SQL Server memory usage. Indeed, SQL server suddenly used all the assigned memory :

enter image description here

I have a good book which say :"Once memory usage has increased beyond the min server memory setting, SQL Server won't release any memory below that amount" - Is the same thing happening here with max server memory ?

enter image description here

I'm wondering (again) how to measure how much memory SQL is really using. I'm confused with the parameter "Total server memory (KB)" ("this counter measures SQL Server's total buffer pool usage"). According perfmon it is only 2MB :

enter image description here

Maybe we could spare the ESX some RAM and SQL Server memory (i.e PLE) will still show good values - How to be sure ? A good explanation on how SQL memory works in that case will be really appreciate!

Was it helpful?

Solution

Indeed, SQL server suddenly used all the assigned memory :

This is pretty much normal and expected, you found out there was low physical memory, you added physical memory and changed max server memory setting now SQL Server can see it has been allowed to use extra memory so it went ahead and grabbed all of it. This would help SQL Server in making things faster when new memory requirements comes because it has already cached memory the new process requiring memory would get that immediately.

I have a good book which say :"Once memory usage has increased beyond the min server memory setting, SQL Server won't release any memory below that amount" - Is the same thing happening here with max server memory ?

Although this is correct but not actually related to what you are seeing. What above says is min server memory is point upto which SQL Server will try to trim down its memory consumption in case of memory pressure what you are seeing is default behavior of SQL Server when more memory is available.

I'm wondering (again) how to measure how much memory SQL is really using. I'm confused with the parameter "Total server memory (KB)" ("this counter measures SQL Server's total buffer pool usage").

If you are using SQL Server 2008 and above easy way to see how much memory SQL Server is using is by querying DMV sys.dm_os_process_memory

select
(physical_memory_in_use_kb/1024)Phy_Memory_usedby_Sqlserver_MB,
(locked_page_allocations_kb/1024 )Locked_pages_used_Sqlserver_MB,
(virtual_address_space_committed_kb/1024 )Total_Memory_UsedBySQLServer_MB,
process_physical_memory_low,
process_virtual_memory_low
from sys. dm_os_process_memory

Phy_Memory_usedby_Sqlserver_MB-- Gives total Physical memory used by SQL Server in MB Total_Memory_UsedBySQLServer_MB-- Gives total memory(RAM+Page file) used by SQL Server in MB

I can also see you are using Task Manager to see SQL Server memory utilization, DON'T use task manager as it will not show correct memory utilized when Locked pages in memory privilege is assigned to SQL Server service account

Total Server Memory: This is simply total memory used by SQL Server BUT this does not tracks ALL memory used and might miss few MB's and this is where DMV comes into picture so always rely on query I have posted.

Now if you see the scale on which you measured Total Server memory is 0.0001 in that case whatever value you are getting you have to multiply it by 10000 to get the value on scale of 1 which is what you need. I cannot see how you got 2 MB can you show it to me.

Long Back I wrote article on SQL Server Memory and Troubleshooting, this should get you started about basics on SQL Server Memory management.

If you are using SQL Server 2012 and above you must read

Leaving enough RAM for OS and ESX in your case is important. If you want to set ideal value for max server memory here is the stackexchange Link

OTHER TIPS

Your configuration is fine. 24GB total RAM, 19GB for SQL Server leaving 5GB for the OS.

SQL Server is memory hungry and will consume all the 19GB available, that is perfectly normal.

You could lower the max server memory from 19GB. I wouldn't do that however, if you were experiencing memory pressure with 12GB of memory.

The question would be what other roles is that server performing that would use the memory you would potentially deallocate from SQL Server? Can those roles (maybe SSIS, SSRS, SSAS etc) be moved to an alternative server?

Look at the scale of the "Total Server Memory (KB)" counter: it's 0.0001. That means that the number you see is divided by 10000, so it's 20 GB instead of 2 MB.

That said, Max Server Memory controls the maximum amount of memory that can be allocated to the SQL Server process. Depending on the version you are using, that setting controls just the buffer pool or all the allocations. SQL Server versions < 2012 control just the size of the buffer pool with that setting, while versions >= 2012 control all memory allocations.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top