Have you enabled Lock Pages in Memory?

Firstly for those that already know about this feature of Windows, have you enabled this permission to your SQL Server service account? If not why not? I’d be interested to know so please leave a comment below.

For those that don’t know….

What is Lock Pages in Memory?

Lock pages in memory is a Windows user permission that you can grant to the SQL Server service account that prevents Windows from paging significant portions of your buffer pool out to disk.

Why should we enable this?

Your buffer pool is the one of the most important parts of SQL Server, it’s your cache, you want to protect it as much as you can! If you find entries in your SQL Server error log that read like this:

“A significant part of SQL Server process memory has been paged out. This may result in a performance degradation.”

Essentially this means that something from the OS is trying to steal memory from SQL Server. If you can identify what it is and stop this from happening then brilliant! Otherwise enable the Lock Pages in Memory setting. The usual culprit for stealing memory is an anti-virus program, but it could be anything that requires a large amount of memory.

How do you enable Lock Pages in Memory?

Essentially in order to resolve the issue follow these instructions:

To enable the lock pages in memory option

  • On the Start menu, click Run. In the Open box, type gpedit.msc.
  • On the Local Group Policy Editor console, expand Computer Configuration, and then expand Windows Settings.
  • Expand Security Settings, and then expand Local Policies.
  • Select the User Rights Assignment folder.

The policies will be displayed in the details pane.

  • In the pane, double-click Lock pages in memory.
  • In the Local Security Setting – Lock pages in memory dialog box, click Add User or Group.
  • In the Select Users, Service Accounts, or Groups dialog box, add the SQL Server service account.
  • Restart the SQL Server service.

Once enabled you should find the error no longer occurs in your error logs.

**Important side note**

Ensure that you set the max memory option in your SQL Server properties. If you don’t SQL Server could then take all the memory away from the OS which could create more problems.