标签:
在学习sql server 内存管理时,看到一些term:memory node,memory clerk,memory object,非常迷惑,在此将自己的理解记录下来,以便后续学习
1,NUMA架构和memory node
内存节点基于硬件 NUMA 创建,memory node是Numa node内的内存块,属于server物理内存的一部分。Memory Node的作用是使得内存的分配由Windows移交到SQL Server OS层面执行。
查看memory node
select * from sys.dm_os_memory_nodes
Memory_node_id=0,不是numa架构,属于smp架构,各个CPU共享一个bus。
Memory_node_id = 64 是DAC专用的。
2,memory clerk
memory clerk(内存记录员),用于分配和回收内存。每个memory node都有自己的memory clerk,只有memory clerk可以访问和分配内存节点。
有很多类型memory clerk,每一个类型的memory clerk用于分配特定用途的内存。memory_node_id标识memory clerk分配和回收的memory node。
重要字段:page_allocator_address
Address of the page allocator. This address is unique for a memory clerk and can be used in sys.dm_os_memory_objects to locate memory objects that are bound to this clerk.
select * from sys.dm_os_memory_clerks
3,memory object
Memory object 从memory clerk获取memory。A memory object requires a memory clerk to allocate its memory。
如果一个sql query 需要使用内存,那么对内存的分配和使用就是memory object,当需要使用内存时,必须通过memory clerk 分配内存。
Memory objects are heaps. They provide allocations that have a finer granularity than those provided by memory clerks. SQL Server components use memory objects instead of memory clerks. Memory objects use the page allocator interface of the memory clerk to allocate pages. Memory objects do not use virtual or shared memory interfaces. Depending on the allocation patterns, components can create different types of memory objects to allocate regions of arbitrary size.
The typical page size for a memory object is 8 KB. However, incremental memory objects can have page sizes that range from 512 bytes to 8 KB.Page size is not a maximum allocation. Instead, page size is allocation granularity that is supported by a page allocator and that is implemented by a memory clerk. You can request allocations greater than 8 KB from memory objects.
查看memory object
select * from sys.dm_os_memory_objects
返回的字段 page_allocator_address 能够和sys.dm_os_memory_clerks的page_allocator_address进行join,表明memory object 是由那个memory clerk分配的。
memory object服务于workder,供worker使用,worker 获取到memory object后,去执行task。
查看sys.dm_os_workers,字段 memory_object_address 是worker使用的memory object的address。
select * from sys.dm_os_workers
由request 查看整个内存的分配信息
select * from sys.dm_exec_requests r inner join sys.dm_os_tasks t on r.task_address=t.task_address inner join sys.dm_os_workers w on t.worker_address=w.worker_address inner join sys.dm_os_memory_objects mo on w.memory_object_address=mo.memory_object_address inner join sys.dm_os_memory_clerks mc on mo.page_allocator_address=mc.page_allocator_address where r.session_id=70
推荐文章:
1,SQLOS‘s memory manager and SQL Server‘s Buffer Pool
http://blogs.msdn.com/b/slavao/archive/2005/02/11/371063.aspx
http://www.cnblogs.com/CareySon/archive/2012/08/16/HowSQLServerManageMemory.html
标签:
原文地址:http://www.cnblogs.com/ljhdo/p/4925760.html