SQL Server 2008 R2未使用已分配的内存
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL Server 2008 R2未使用已分配的内存相关的知识,希望对你有一定的参考价值。
我有一个通过VM运行的sql实例。 VM分配了32GB的内存,我设置使用28GB。但是,看看内存使用情况,我只看到SQL使用大约1GB。它还显示除了1gb之外的所有内容都是免费的,但是使用的进程不会增加到31gb。甚至没有关闭,我看到可能总共3gb。
我已经附加了一些TSQL结果用于内存使用。
Memory usage details for SQL Server instance- X64) - Enterprise Edition (64-bit))
----------------------------------------------------------------------------------------------------
--------------------------------------
Memory visible to the Operating System
Physical Memory_MB Physical Memory_GB Virtual Memory GB
--------------------------------------- --------------------------------------- ---------------------------------------
32768 32 8192
-------------------------------
Buffer Pool Usage at the Moment
BPool_Committed_MB BPool_Commit_Tgt_MB BPool_Visible_MB
--------------------------------------- --------------------------------------- ---------------------------------------
28672.000000 28672.000000 28672.000000
---------------------------------------------------------------------------
Total Memory used by SQL Server Buffer Pool as reported by Perfmon counters
Mem_KB Mem_MB Mem_GB
-------------------- --------------------------------------- ---------------------------------------
29360128 28672.000000 28.000000000
-------------------------------------------------------------
Memory needed as per current Workload for SQL Server instance
Mem_KB Mem_MB Mem_GB
-------------------- --------------------------------------- ---------------------------------------
29360128 28672.000000 28.000000000
------------------------------------------------------------------------------
Total amount of dynamic memory the server is using for maintaining connections
Mem_KB Mem_MB Mem_GB
-------------------- --------------------------------------- ---------------------------------------
5288 5.164062 0.005043029
------------------------------------------------------------
Total amount of dynamic memory the server is using for locks
Mem_KB Mem_MB Mem_GB
-------------------- --------------------------------------- ---------------------------------------
31248 30.515625 0.029800415
----------------------------------------------------------------------------
Total amount of dynamic memory the server is using for the dynamic SQL cache
Mem_KB Mem_MB Mem_GB
-------------------- --------------------------------------- ---------------------------------------
40752 39.796875 0.038864135
-------------------------------------------------------------------------
Total amount of dynamic memory the server is using for query optimization
Mem_KB Mem_MB Mem_GB
-------------------- --------------------------------------- ---------------------------------------
2528 2.468750 0.002410888
-------------------------------------------------------------------------------
Total amount of dynamic memory used for hash, sort and create index operations.
Mem_KB Mem_MB Mem_GB
-------------------- --------------------------------------- ---------------------------------------
0 0.000000 0.000000000
------------------------------------------
Total Amount of memory consumed by cursors
Mem_KB Mem_MB Mem_GB
-------------------- --------------------------------------- ---------------------------------------
1832 1.789062 0.001747131
-------------------------------------------------------------------------
Number of pages in the buffer pool (includes database, free, and stolen).
8KB_Pages Pages_in_KB Pages_in_MB
-------------------- --------------------------------------- ---------------------------------------
3670016 29360128.000000 28672.000000000
---------------------------------------
Number of Data pages in the buffer pool
8KB_Pages Pages_in_KB Pages_in_MB
-------------------- --------------------------------------- ---------------------------------------
1429714 11437712.000000 11169.640625000
---------------------------------------
Number of Free pages in the buffer pool
8KB_Pages Pages_in_KB Pages_in_MB
-------------------- --------------------------------------- ---------------------------------------
1887521 15100168.000000 14746.257812500
-------------------------------------------
Number of Reserved pages in the buffer pool
8KB_Pages Pages_in_KB Pages_in_MB
-------------------- --------------------------------------- ---------------------------------------
0 0.000000 0.000000000
-----------------------------------------
Number of Stolen pages in the buffer pool
8KB_Pages Pages_in_KB Pages_in_MB
-------------------- --------------------------------------- ---------------------------------------
352781 2822248.000000 2756.101562500
---------------------------------------------
Number of Plan Cache pages in the buffer pool
8KB_Pages Pages_in_KB Pages_in_MB
-------------------- --------------------------------------- ---------------------------------------
357949 2863592.000000 2796.476562500
-----------------------------------------------------------------------------------------------
Page Life Expectancy - Number of seconds a page will stay in the buffer pool without references
Page Life in seconds PLE Status
-------------------- ------------------
81046 PLE is Healthy
--------------------------------------------------------------
Number of requests per second that had to wait for a free page
Free list stalls/sec
--------------------
77
-----------------------------------------------------------------------------------------------------------------
Number of pages flushed to disk/sec by a checkpoint or other operation that require all dirty pages to be flushed
Checkpoint pages/sec
--------------------
786108
------------------------------------------------------------------------
Number of buffers written per second by the buffer manager"s lazy writer
Lazy writes/sec
--------------------
5157
--------------------------------------------------------------
Total number of processes waiting for a workspace memory grant
Memory Grants Pending
---------------------
0
----------------------------------------------------------------------------------
Total number of processes that have successfully acquired a workspace memory grant
Memory Grants Outstanding
-------------------------
0
Per Shanky的要求。
physical_memory_in_use_kb = 30784516
large_page_allocations_kb = 196608
locked_page_allocations_kb = 30285504
total_virtual_address_space_kb = 8589934464
virtual_address_space_reserved_kb = 34544372
virtual_address_space_committed_kb = 31110044
virtual_address_space_available_kb = 8555390092
page_fault_count = 1706349
memory_utilization_percentage = 100
available_commit_limit_kb = 34625996
process_physical_memory_low = 0
process_virtual_memory_low = 0
因此,基于此,看起来一切看起来都很棒。但这并不能解释为什么服务器会随着时间的推移开始变慢,就像内存被其他虚拟机窃取一样。看到这些结果后,这个问题可能已经变成了完全不同的东西。
通过最大服务器内存为SQL Server分配了多少内存。您发布的信息不包括在内。
您还可以添加以下查询的输出,请格式化问题,以便输出清晰可见
select * from sys.dm_os_process_memory
你永远不应该看任务管理器的SQL Server内存消耗。它是一个Windows工具,只提供有关Working Set memory的信息,而不是SQL Server消耗的总内存。如果SQL Server服务帐户在本地系统下运行,或者服务帐户具有内存中的锁定页面权限(LPIM),则任务管理器将不显示由AWE API(或锁定的内存)分配的内存。
任务管理器显示的工作集内存可以通过操作系统进行分页,但是由AWE API分配的内存(当SQL Server服务帐户具有LPIM时)无法被分页,这就是为什么它被称为locked
。在您的情况下,我猜SQL Server服务帐户具有LPIM,因此任务管理器不显示由AWE API仅分配工作集的内存
在查询输出中,如果您看到locked_page_allocations_kb的某个值,则SQL帐户具有LPIM。
编辑:
从查询结果
locked_page_allocations_kb = 30285504~ 28 G
这是SQL Server使用的总内存的一部分(被锁定的内存),这不会在任务管理器下显示。任务管理器不会显示此信息,因为它是NON PAGEABLE内存,而任务管理器仅报告可分页的工作集。
现在你问到为什么运行大查询时SQL Server内存消耗上升的原因是因为缓冲池开始获取新页面导致内存消耗增加因此利用率增加
以上是关于SQL Server 2008 R2未使用已分配的内存的主要内容,如果未能解决你的问题,请参考以下文章
win12安装 sqlserver2008 r2未授权的操作
如果已附加数据库,如何使用 Transact-SQL 和 SQL Server 2008 R2 进行测试? [复制]