Welcome to MSDN Blogs Sign in | Join | Help

Do I have to assign the Lock Pages in Memory privilege for Local System?

NOTE: I've updated this because of some questions about 32bit systems. 

Some who attended one of my talks at the recent PASS conference asked me the following question "Do I need to use the Group Policy Editor to assign the Lock Pages in Memory privilege if my SQL Server Service is running under the Local System Account?". The answer to this question is no and here is why. First let me explain, how this works for 64bit systems:

If you want to determine whether SQL Server 2005 64bit systems are actually taking advantage of the Lock Pages in Memory privilege, look for the following entry in your SQL ERRORLOG when it is starting up:

Using locked pages for buffer pool

If you don't see this message, the policy was not set correctly or set for the wrong account (or you are not using Enterprise Edition). If you do see this message, then SQL Server recognizes this privilege for the account associated with the SQL Server Service.

So the next logical question is how does SQL Server decide to print this message? Well here is the algorithm:

1) Call the AdjustTokenPrivileges() API to enable the SeLockMemoryPrivilege based on the current process access token.
2) Call GetLastError() to see if this API was successful.
3) If this call was successful and the SKU is Enterprise Edition, we print the message in the ERRORLOG and we take advantage of this privilege.

On my Windows 2003 Enterprise Edition SP2 Server, I ran the Group Policy Object Editor as described at http://msdn2.microsoft.com/en-us/library/ms190730.aspx. On my system, no users had this privilege and to no surprise this entry was not in my ERRORLOG. I then added the domain account to this privilege associated with the SQL Server service using the policy editor and restarted SQL Server. Now this entry was in my ERRORLOG. I then changed the logon account for my SQL Server service to Local System and restarted SQL Server. The entry remained in my ERRORLOG. But the the Group Policy Object Editor does not show the SYSTEM account in its list of users who have the Locked Pages in Memory privilege.

If you are using 32bit systems, the messages and algorithm are slightly different. The message you should look for in the ERRORLOG is the following: 

Address Windowing Extensions is enabled

If the privilege was not set correctly, you will see this message:

Could not use Address Windowing Extensions because the 'lock pages in memory' privilege was not granted.

These messages will NOT show up for 32bit systems unless the configuration value 'awe enabled' is set to 1. So the algorithm for 32bit systems is:

  • If 'awe enabled' = 0 but there is enough physical memory that AWE might help you (more on that at later), then print the message

Set AWE Enabled to 1 in the configuration parameters to allow use of more memory.

Otherwise, don't print any message

  • Else If 'awe enabled' = 1 and the "lock pages in memory check" as above is TRUE, then print the message that AWE is enabled.
  • Else if 'awe enabled' = 1 and the "lock pages in memory check" as above is FALSE, then print the message that AWE cannot be enabled.

The message "Set AWE Enabled to 1 in the configuration parameters to allow use of more memory" is printed if the size of the Virtual Address space is < the amount of physical memory on the machine (or the 'max server memory' option). So on a 32bit machine where /3GB is being used, if the machine has 4Gb of physical RAM, we will print this message if 'awe enabled' = 0.

A question to ask here is why do you need to enable AWE for 32bit systems to use lock pages in memory privilege?That question is actually the wrong one to ask but helps explain a few things. For 32bit systems, the main reason we designed SQL Server to use the AWE APIs is to access more memory than its virtual address space will allow (>4Gb). But to use the AWE APIs, the 'lock pages in memory' privilege must be set. 

For 64bit systems, the virtual address space limitation is not an issue. However, if an application wants to "lock its memory" or avoid its working set from being trimmed, then it can achieve this by using the AWE APIs. Again, in order to use these APIs, you must have the 'lock pages in memory' privilege set. This is why for 64bit systems, you don't need to set the 'awe enabled' option to 1 (it is actually ignored on 64bit systems).

So, the purpose of AWE for 32bit systems was to access more memory. But for 64bit, AWE APIs are used to avoid a working set trim. So SQL Server will automatically use the AWE APIs provided the 'lock pages in memory' privilege is set (and your are using Enterprise Edition). If you want to read more about the AWE APIs, look here in MSDN: http://msdn2.microsoft.com/en-us/library/aa366527.aspx

So after all of this (but I hope you found the details helpful) back to the original question and my conclusion. The Local System account has the 'lock pages in memory' privilege by default. For user accounts, you must grant the account this privilege explicitly.

Bob Ward, Microsoft

Published Thursday, October 18, 2007 3:46 PM by psssql

Comments

# Techy News Blog &raquo; Blog Archive &raquo; Do I have to assign the Lock Pages in Memory privilege for Local System?

# NetworkService?

Saturday, October 20, 2007 10:46 AM by mbourgon

I was trying to get AWE and Database Mail enabled on a x64, 2005 box.  The machine was set up to use the NetworkService account, and I couldn't get AWE enabled without enabling the lock pages in memory setting.  What was doubly odd was that none of the other sp_configure settings that I changed took effect prior to enabling that.  RECONFIGURE would say that the Lock Pages In Memory had to be set first, and wouldn't enable mail until that was done.  

Just found that terribly odd.

# re: Do I have to assign the Lock Pages in Memory privilege for Local System?

Tuesday, October 23, 2007 4:33 PM by alpha1105omega

i have lock pages in memory set in gpedit..

however i cannot locate this messsage in sql errorlog (Log File Viewer in SSMS or ERRORLOG files) "Using locked pages for buffer pool"..

???

Are you positive that "lock page in memory" privilege is set for the account that that the SQL Server Service is logged on with? Also, this only for Enterprise Edition.

bob ward

# re: Do I have to assign the Lock Pages in Memory privilege for Local System?

Tuesday, October 23, 2007 6:53 PM by alpha1105omega

my 64bit says "Using locked pages for buffer pool"..

but cant find the message in 32bit however it says address windowsing extension..is enabled......

is it only applies to 64bit?

This is a great question and has caused me to go back and look at how we print this messagei in the ERRORLOG. I'm going to update the blog with new information that covers your questions and sets a few other facts straight.

bob ward

# Configuring Windows 2003 ( x64 ) for SQL Server

Sunday, January 06, 2008 3:49 PM by Grumpy Old DBA

There is an almost constant stream of posts on forums asking about configuration of SQL Server 2005 memory,

# Why Should I use SQL Enterprise Edition?

Thursday, January 24, 2008 8:31 AM by Bob Duffy's Blobby Blog

A lot of customers have been asking me if they need to use Enterprise Edition. the basic answer is that

# Welcome -- Ax Database Configuration Checklist part 1

Wednesday, March 12, 2008 2:52 PM by Dynamics Ax Performance team

Welcome to the Dynamics Ax Performance Team's blog. We're putting together a team introduction and hope

# Why Should I use SQL Enterprise Edition?

Sunday, March 30, 2008 6:20 PM by Bob Duffy's Blobby Blog

A lot of customers have been asking me if they need to use Enterprise Edition. the basic answer is that

Anonymous comments are disabled
 
Page view tracker