Skip to content

Commit 1f52f23

Browse files
authored
Merge pull request #21874 from rwestMSFT/rw-0427-memory-consumers
Update dm_xtp_system_memory_consumers
2 parents 7d8eb36 + 3900aeb commit 1f52f23

1 file changed

Lines changed: 85 additions & 78 deletions

File tree

Lines changed: 85 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
description: "sys.dm_xtp_system_memory_consumers (Transact-SQL)"
3-
title: "sys.dm_xtp_system_memory_consumers (Transact-SQL) | Microsoft Docs"
2+
description: "Reports system level memory consumers for In-Memory OLTP."
3+
title: "sys.dm_xtp_system_memory_consumers (Transact-SQL)"
44
ms.custom: ""
5-
ms.date: "06/10/2016"
5+
ms.date: 04/27/2022
66
ms.prod: sql
77
ms.reviewer: ""
88
ms.technology: system-objects
@@ -21,87 +21,94 @@ author: rwestMSFT
2121
ms.author: randolphwest
2222
---
2323
# sys.dm_xtp_system_memory_consumers (Transact-SQL)
24+
2425
[!INCLUDE [SQL Server Azure SQL Database](../../includes/applies-to-version/sql-asdb.md)]
2526

26-
Reports system level memory consumers for [!INCLUDE[hek_2](../../includes/hek-2-md.md)]. The memory for these consumers comes either from the default pool (when the allocation is in the context of a user thread) or from internal pool (if the allocation is in the context of a system thread).
27-
27+
Reports system level memory consumers for [!INCLUDE[hek_2](../../includes/hek-2-md.md)]. The memory for these consumers comes either from the default pool (when the allocation is in the context of a user thread) or from the internal pool (if the allocation is in the context of a system thread).
28+
2829
```sql
29-
-- system memory consumers @ instance
3030
SELECT *
31-
FROM sys.dm_xtp_system_memory_consumers
32-
```
33-
34-
For more information, see [In-Memory OLTP (In-Memory Optimization)](../in-memory-oltp/overview-and-usage-scenarios.md).
35-
36-
|Column name|Type|Description|
37-
|-----------------|----------|-----------------|
38-
|memory_consumer_id|**bigint**|Internal ID for memory consumer.|
39-
|memory_consumer_type|**int**|An integer that represents the type of the memory consumer with one of the following values:<br /><br /> 0 - It should not be displayed. Aggregates memory usage of two or more consumers.<br /><br /> 1 - LOOKASIDE: Tracks memory consumption for a system lookaside.<br /><br /> 2 - VARHEAP: Tracks memory consumption for a variable-length heap.<br /><br /> 4 - IO page pool: Tracks memory consumption for a system page pool used for IO operations.|
40-
|memory_consumer_type_desc|**nvarchar(16)**|The description of the type of memory consumer:<br /><br /> 0 - It should not be displayed.<br /><br /> 1 - LOOKASIDE<br /><br /> 2 - VARHEAP<br /><br /> 4 - PGPOOL|
41-
|memory_consumer_desc|**nvarchar(64)**|Description of the memory consumer instance:<br /><br /> VARHEAP: <br />System heap. General purpose. Currently only used to allocate garbage collection work items.<br />-OR-<br />Lookaside heap. Used by looksides when the number of items contained in the lookaside list reaches a predetermined cap (usually around 5,000 items).<br /><br /> PGPOOL: For IO system pools there are three different sizes: System 4K page pool, System 64 K page pool, and System 256 K page pool.|
42-
|lookaside_id|**bigint**|The ID of the thread-local, lookaside memory provider.|
43-
|pagepool_id|**bigint**|The ID of the thread-local, page pool memory provider.|
44-
|allocated_bytes|**bigint**|Number of bytes reserved for this consumer.|
45-
|used_bytes|**bigint**|Bytes used by this consumer. Applies only to varheap memory consumers.|
46-
|allocation_count|**int**|Number of allocations.|
47-
|partition_count|**int**|Internal use only.|
48-
|sizeclass_count|**int**|Internal use only.|
49-
|min_sizeclass|**int**|Internal use only.|
50-
|max_sizeclass|**int**|Internal use only.|
51-
|memory_consumer_address|**varbinary**|Internal address of the consumer.|
52-
53-
## Permissions
54-
Requires VIEW SERVER STATE permissions on the server.
55-
56-
## User Scenario
57-
31+
FROM sys.dm_xtp_system_memory_consumers;
32+
```
33+
34+
For more information, see [In-Memory OLTP &#40;In-Memory Optimization&#41;](../in-memory-oltp/overview-and-usage-scenarios.md).
35+
36+
|Column name|Type|Description|
37+
|-----------------|----------|-----------------|
38+
|memory_consumer_id|**bigint**|Internal ID for memory consumer.|
39+
|memory_consumer_type|**int**|An integer that represents the type of the memory consumer with one of the following values:<br /><br />0 - Should not be displayed. Aggregates memory usage of two or more consumers.<br /><br />1 - LOOKASIDE: Tracks memory consumption for a system lookaside.<br /><br />2 - VARHEAP: Tracks memory consumption for a variable-length heap.<br /><br />4 - IO page pool: Tracks memory consumption for a system page pool used for IO operations.|
40+
|memory_consumer_type_desc|**nvarchar(16)**|The description of the type of memory consumer:<br /><br />0 - Should not be displayed<br /><br />1 - LOOKASIDE<br /><br />2 - VARHEAP<br /><br />4 - PGPOOL|
41+
|memory_consumer_desc|**nvarchar(64)**|Description of the memory consumer instance:<br /><br />VARHEAP:<br />System heap. General purpose. Currently only used to allocate garbage collection work items.<br />-OR-<br />Lookaside heap. Used by lookasides when the number of items contained in the lookaside list reaches a predetermined cap (usually around 5,000 items).<br /><br />PGPOOL: For IO system pools there are three different sizes: System 4K page pool, System 64 K page pool, and System 256 K page pool.|
42+
|lookaside_id|**bigint**|The ID of the thread-local, lookaside memory provider.|
43+
|pagepool_id|**bigint**|The ID of the thread-local, page pool memory provider.|
44+
|allocated_bytes|**bigint**|Number of bytes reserved for this consumer.|
45+
|used_bytes|**bigint**|Bytes used by this consumer. Applies only to varheap memory consumers.|
46+
|allocation_count|**int**|Number of allocations.|
47+
|partition_count|**int**|Internal use only.|
48+
|sizeclass_count|**int**|Internal use only.|
49+
|min_sizeclass|**int**|Internal use only.|
50+
|max_sizeclass|**int**|Internal use only.|
51+
|memory_consumer_address|**varbinary**|Internal address of the consumer.|
52+
53+
## Permissions
54+
55+
Requires VIEW SERVER STATE permissions on the server.
56+
57+
## User scenario
58+
59+
This example outputs the system memory consumers for the SQL Server instance:
60+
5861
```sql
59-
-- system memory consumers @ instance
60-
SELECT memory_consumer_type_desc, allocated_bytes/1024 as allocated_bytes_kb,
61-
used_bytes/1024 as used_bytes_kb, allocation_count
62-
FROM sys.dm_xtp_system_memory_consumers
63-
```
64-
65-
The output shows all memory consumers at system level. For example, there are consumers for transaction look aside.
66-
67-
```
68-
memory_consumer_type_name memory_consumer_desc allocated_bytes_kb used_bytes_kb allocation_count
69-
------------------------------- --------------------- ------------------- -------------- ----------------
70-
VARHEAP Lookaside heap 0 0 0
71-
VARHEAP System heap 768 0 2
72-
LOOKASIDE GC transaction map entry 64 64 910
73-
LOOKASIDE Redo transaction map entry 128 128 1260
74-
LOOKASIDE Recovery table cache entry 448 448 8192
75-
LOOKASIDE Transaction recent rows 3264 3264 4444
76-
LOOKASIDE Range cursor 0 0 0
77-
LOOKASIDE Hash cursor 3200 3200 11070
78-
LOOKASIDE Transaction save-point set entry 0 0 0
79-
LOOKASIDE Transaction partially-inserted rows set 704 704 1287
80-
LOOKASIDE Transaction constraint set 576 576 1940
81-
LOOKASIDE Transaction save-point set 0 0 0
82-
LOOKASIDE Transaction write set 704 704 672
83-
LOOKASIDE Transaction scan set 320 320 156
84-
LOOKASIDE Transaction read set 704 704 343
85-
LOOKASIDE Transaction 4288 4288 1459
86-
PGPOOL System 256K page pool 5120 5120 20
87-
PGPOOL System 64K page pool 0 0 0
88-
PGPOOL System 4K page pool 24 24 6
89-
```
90-
91-
To see the total memory consumed by system allocators:
92-
62+
SELECT memory_consumer_type_desc,
63+
memory_consumer_desc,
64+
allocated_bytes / 1024 as allocated_bytes_kb,
65+
used_bytes / 1024 as used_bytes_kb,
66+
allocation_count
67+
FROM sys.dm_xtp_system_memory_consumers;
68+
```
69+
70+
The output shows all memory consumers at system level. For example, there are consumers for transaction look aside.
71+
72+
```output
73+
memory_consumer_type_desc memory_consumer_desc allocated_bytes_kb used_bytes_kb allocation_count
74+
------------------------------- --------------------- ------------------- -------------- ----------------
75+
VARHEAP Lookaside heap 0 0 0
76+
VARHEAP System heap 768 0 2
77+
LOOKASIDE GC transaction map entry 64 64 910
78+
LOOKASIDE Redo transaction map entry 128 128 1260
79+
LOOKASIDE Recovery table cache entry 448 448 8192
80+
LOOKASIDE Transaction recent rows 3264 3264 4444
81+
LOOKASIDE Range cursor 0 0 0
82+
LOOKASIDE Hash cursor 3200 3200 11070
83+
LOOKASIDE Transaction save-point set entry 0 0 0
84+
LOOKASIDE Transaction partially-inserted rows set 704 704 1287
85+
LOOKASIDE Transaction constraint set 576 576 1940
86+
LOOKASIDE Transaction save-point set 0 0 0
87+
LOOKASIDE Transaction write set 704 704 672
88+
LOOKASIDE Transaction scan set 320 320 156
89+
LOOKASIDE Transaction read set 704 704 343
90+
LOOKASIDE Transaction 4288 4288 1459
91+
PGPOOL System 256K page pool 5120 5120 20
92+
PGPOOL System 64K page pool 0 0 0
93+
PGPOOL System 4K page pool 24 24 6
94+
```
95+
96+
To see the total memory consumed by system allocators:
97+
9398
```sql
94-
SELECT SUM(allocated_bytes)/(1024*1024) AS total_allocated_MB, SUM(used_bytes)/(1024*1024) AS total_used_MB
95-
FROM sys.dm_xtp_system_memory_consumers
99+
SELECT SUM(allocated_bytes) / (1024 * 1024) AS total_allocated_MB,
100+
SUM(used_bytes) / (1024 * 1024) AS total_used_MB
101+
FROM sys.dm_xtp_system_memory_consumers;
96102
```
97-
Here is the result set.
98103

104+
Here is the result set.
105+
106+
```output
107+
total_allocated_MB total_used_MB
108+
-------------------- --------------------
109+
2 2
99110
```
100-
total_allocated_MB total_used_MB
101-
-------------------- --------------------
102-
2 2
103-
```
104-
105-
## See Also
106-
[Memory-Optimized Table Dynamic Management Views &#40;Transact-SQL&#41;](../../relational-databases/system-dynamic-management-views/memory-optimized-table-dynamic-management-views-transact-sql.md)
107-
111+
112+
## See also
113+
114+
- [Memory-Optimized Table Dynamic Management Views &#40;Transact-SQL&#41;](../../relational-databases/system-dynamic-management-views/memory-optimized-table-dynamic-management-views-transact-sql.md)

0 commit comments

Comments
 (0)