SQL Memory and Sizing Considerations
I am getting info about this article from https://support.microsoft.com/en-us/kb/2663912
I had recently interviewed for Microsoft SQL PFE position and failed miserably when they asked me about Max Memory (that is why I am not working there yet)
- What does it do?
- When you configure it, does SQL Engine utilize all of it
After answering the questions, the technical interviewers were nice enough to explain why I was wrong. I decided to learn more on it and found the article in the above link.
One thing to remember before we get started that MAX MEMORY behavior was changed starting SQL 2012 and beyond. All versions including SQL 2008 R2 and prior handled memory differently.
Summary:
MS SQL Engine manages automatic and dynamic memory requirements based on current memory needs of the internal SQL components and workload. There are options to fine tune specific behaviors to meet needs of SQL. One the option we are discussing is MIN MEMORY and MAX MEMORY.
Info:
With SQL 2012, new changes were introduced to include specific types of memory allocations. Let me explain some of these terms
Types of Memory Allocations:
- Single-page Allocations: Memory allocations requests less than or equal to 8K are referred to Single-page Allocations used by SQL Server processes.
- Multi-page Allocations: These are the allocations that request more than 8K pages. What could cause them, one of the examples I found was an example of workload that has stored procedures with large number of parameters and then invoked via large ad-hoc batches. You can read more about it here
- CLR allocations: These allocations include the SQL CLR heaps and its global allocations that are created during CLR initialization.
- Thread Stacks Memory: Memory used for thread stacks within SQL Server Process (Max worker thread * thread stack size). Thread stack size is 512K in 32 bit SQL Server, 904K in WOW mode, and 2 MB in 64 Bit.
- Direct Allocations from Windows: Direct windows allocations made by Non-SQL Server DLL’s ([These include windows heap usage and direct virtual allocations made by modules loaded into SQL Server process. Examples: allocations from extended stored procedure DLL’s, objects created using OLE Automation procedures (sp_OA calls), allocations from linked server providers loaded in SQL Server process)
SQL 2005, SQL 2008, SQL 2008 R2:
| Type of memory allocation | Supported |
| Single-page allocations | YES |
| Multi-page allocations | NO |
| CLR allocations | NO |
| Thread stacks memory | NO |
| Direct allocations from Windows | NO |
SQL 2012, SQL 2014, SQL 2016:
Starting with SQL 2012, Single-page and Multi-page memory allocation are included in Any Size Page Allocator. You can read more about it here
| Type of memory allocation | Supported |
| Single-page allocations | Yes - As part of Any size Page Allocator |
| Multi-page allocations | Yes - As part of Any size Page Allocator |
| CLR allocations | YES |
| Thread stacks memory | NO |
| Direct allocations from Windows | NO |
Hopefully this will help you understand Max and Min memory for SQL server. If you like to learn more in detail, I have included links within this article.
Thanks!