Many of the SQL Server blog mention SQL Server use VirtualAlloc() to allocate the memory. Many of them also mention when use AWE or LPIM in SQL 2012, SQL server use AllocateUserPhysicalPages to allocate the page outside the working set to prevent the memory being page out.
In PASS SUMMIT 2012, Bob Ward show how to use WinDbg to track the VirtualAlloc, this trigger my curiosity. Can I also see AllocateUserPhysicalPages in the call stack? The answer should be yes, but the journal takes longer than I thought.
Here are my Lab environment:
Lab Setup
- VM1: 64-bit Windows 2008R2 , SQL Server 2012
- VM2: 64-bit Windows 2008R2, SQL Server 2008R2
Both Hosts, I have LPIM enable . You can refer here for how to enable LPIM I can confirm the LPIM is enable from error log.
virtualalloc
Here are the steps I find the VirtualAlloc call.
- Open command line window with administrator privilege
- Start Wingbg as below:
set path=%path%;C:\Program Files (x86)\Windows Kits\8.1\Debuggers\x64
cd C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Binn
windbg -y srv*c:\public_symbols*http://msdl.microsoft.com/download/symbols sqlservr.exe -sMSSQLSERVER
and type , bp is to set the break point,
bp kernelbase!VirtualAlloc
and hit g until it hit the break point and hit k to print the call stack.