熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> SQL Server >> 正文

為什麼SQL Server使用很少的內存

2022-06-13   來源: SQL Server 

  SQL Server的內存一直上不去從Task Schedule中看到SQL Server只使用了MB內存實際這台機器有GB的內存可用內存有超過GB

  當時我以為是開啟了AWE導致的所以連接到他的服務器看了一下但是數據庫為企業版所以不用開啟AWE而且即使開啟了也會被忽略

  使用下面的腳本查詢了一下SQL Server內存使用

  select physical_memory_in_use_kblocked_page_allocations_kb*fromsysdm_os_process_memory

  看到實際使用的內存有GB遠遠超出任務管理器看到的(也可以通過Perfmon的Total server memory(MB)查看)

  當時覺得很奇怪查看了SQL Server錯誤日志發現了類似下面的信息

  :: Server Large Page Extensions enabled

   :: Server Large Page Granularity:

   :: Server Large Page Allocated: MB

  猜測這台期間開啟了Lock Pages In memory功能之後得到確認因為開啟Lock Pages In memory之後SQL Server會使用AWE APIs鎖定內存頁所以這部分的內存使用不會顯示在Working Set中

  So in summary the AWE APIs for bit and bit SQL Server systems are used for different purposes In bit it is really to extend memory access beyond Gb or to enable the AWE feature For bit systems it is to possibly gain performance and to “lock pages” for the buffer pool

  到現在這個問題就比較明朗了其實SQL Server還是正常工作的一般查詢SQL Server的使用還是建議使用DMV或者Perfmon直接查看Working Set信息可能不准

  另外說一下當時看到上面Large Page的信息以為是數據庫開啟了LargePage但是使用DBCC TRACSTATUS查看沒有開啟 Trace Flag所以大數據功能是沒有啟用的只有開啟 Trace Flag數據庫才會真正啟用Large Page

  啟用Large page在數據庫錯誤日志會看到類似信息

  :: Server Using large pages for buffer pool

  關於Lock Pages In memory/working set機制我找到了兩篇文章大家有興趣可以參考

  Funwith Locked Pages AWE Task Manager and the Working Set

  WhySQL Server is using so LESS memory


From:http://tw.wingwit.com/Article/program/SQLServer/201311/22296.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.