Memory-Optimized Table Memory Allocated issues
I have Some In-Memory OLTP objects in SQL Server and it's version SQL Server 2016 SP2-CU4.
I have a problem because of data row-size of some tables greater than 8060bytes, so there was some off-row storage in internal xtp DMVs and those tables allocated a memory about 120GB.
I alter that tables and reduce row-size to less than 8060 bytes, the memory allocated to those tables reduce and the allocated memory to object_id=0 is being grow in sys.dm_db_xtp_table_memory_stats and it's about 50GB. I think The garbage collector thread cant find this orphaned object , thus it cant deallocate memory.
another issue is 'Memory Allocated To Memory Optimized Objects' is 25GB where 'Memory Used By Memory Optimized Objects' is 62GB, may be I think this is a bug
how I can deallocate this memory ?!


sql-server sql-server-2016
add a comment |
I have Some In-Memory OLTP objects in SQL Server and it's version SQL Server 2016 SP2-CU4.
I have a problem because of data row-size of some tables greater than 8060bytes, so there was some off-row storage in internal xtp DMVs and those tables allocated a memory about 120GB.
I alter that tables and reduce row-size to less than 8060 bytes, the memory allocated to those tables reduce and the allocated memory to object_id=0 is being grow in sys.dm_db_xtp_table_memory_stats and it's about 50GB. I think The garbage collector thread cant find this orphaned object , thus it cant deallocate memory.
another issue is 'Memory Allocated To Memory Optimized Objects' is 25GB where 'Memory Used By Memory Optimized Objects' is 62GB, may be I think this is a bug
how I can deallocate this memory ?!


sql-server sql-server-2016
add a comment |
I have Some In-Memory OLTP objects in SQL Server and it's version SQL Server 2016 SP2-CU4.
I have a problem because of data row-size of some tables greater than 8060bytes, so there was some off-row storage in internal xtp DMVs and those tables allocated a memory about 120GB.
I alter that tables and reduce row-size to less than 8060 bytes, the memory allocated to those tables reduce and the allocated memory to object_id=0 is being grow in sys.dm_db_xtp_table_memory_stats and it's about 50GB. I think The garbage collector thread cant find this orphaned object , thus it cant deallocate memory.
another issue is 'Memory Allocated To Memory Optimized Objects' is 25GB where 'Memory Used By Memory Optimized Objects' is 62GB, may be I think this is a bug
how I can deallocate this memory ?!


sql-server sql-server-2016
I have Some In-Memory OLTP objects in SQL Server and it's version SQL Server 2016 SP2-CU4.
I have a problem because of data row-size of some tables greater than 8060bytes, so there was some off-row storage in internal xtp DMVs and those tables allocated a memory about 120GB.
I alter that tables and reduce row-size to less than 8060 bytes, the memory allocated to those tables reduce and the allocated memory to object_id=0 is being grow in sys.dm_db_xtp_table_memory_stats and it's about 50GB. I think The garbage collector thread cant find this orphaned object , thus it cant deallocate memory.
another issue is 'Memory Allocated To Memory Optimized Objects' is 25GB where 'Memory Used By Memory Optimized Objects' is 62GB, may be I think this is a bug
how I can deallocate this memory ?!


sql-server sql-server-2016
sql-server sql-server-2016
edited Dec 22 at 4:59
asked Dec 20 at 9:09
Ehsan HP
314
314
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You should check out this blog post from the king of In-Memory OLTP, Ned Otter:
Row version lifecycle for In-Memory OLTP
In particular, this passage:
2. Deallocating rows from memory
...
So the two triggers for Garbage Collection are memory pressure and/or transactional activity. Conversely, that means if there’s no memory pressure – or transactional activity is low – it’s perfectly reasonable to have row versions that aren’t garbage collected. There’s also no way to force garbage collection to occur.
So this is just to clarify that there are situations where garbage collection may not occur, or may occur slowly.
The post goes on to discuss that long-running queries on in-memory tables will completely block garbage collection, so make sure to check for any of those.
The reason the screenshot of SSMS is off (used it higher than allocated) is because it's purely based on the DMVs, so the NULL memory_allocated_for_table_kb throws off the calculation. This is what runs when you open the database properties window:
SELECT
isnull((
select convert(decimal(18,2),(sum(tms.memory_allocated_for_table_kb) + sum(tms.memory_allocated_for_indexes_kb)))
from [sys].[dm_db_xtp_table_memory_stats] tms)
, 0.00) AS [MemoryAllocatedToMemoryOptimizedObjectsInKB]
SELECT
isnull((
select convert(decimal(18,2),(sum(tms.memory_used_by_table_kb) + sum(tms.memory_used_by_indexes_kb)))
from [sys].[dm_db_xtp_table_memory_stats] tms)
, 0.00) AS [MemoryUsedByMemoryOptimizedObjectsInKB]
I'm still not really sure what the purpose of that object_id = 0 row is in dm_db_xtp_table_memory_stats. I can repeat the behavior locally (create a table with LOB data, then ALTER the column to fit in-row, suddenly I have that same 0 result), but I don't know if it's a problem.
It's possible that it's normal overhead related to in-memory OLTP, but it might be a bug. If it's causing significant problems, I'd suggest opening a case with Microsoft. There have been bugs before related to memory usage with LOB data, see MSDN Forums | In Memory OLTP for an example, and this CU: FIX: Out-of-memory error when you run a query to access LOB columns through In-Memory OLTP in SQL Server 2016.
I attached it the related image, I get it at database options in General tab.
– Ehsan HP
Dec 22 at 5:06
@Ehs thanks! You still haven't mentioned the query you're running to get the results in your first screenshot. Is it just selecting fromsys.dm_db_xtp_table_memory_stats, or are you joining to other tables / DMVs?
– jadarnel27
Dec 22 at 15:15
yeah, I get result from sys.dm_db_xtp_table_memory_stats ,
– Ehsan HP
Dec 23 at 6:10
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f225447%2fmemory-optimized-table-memory-allocated-issues%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should check out this blog post from the king of In-Memory OLTP, Ned Otter:
Row version lifecycle for In-Memory OLTP
In particular, this passage:
2. Deallocating rows from memory
...
So the two triggers for Garbage Collection are memory pressure and/or transactional activity. Conversely, that means if there’s no memory pressure – or transactional activity is low – it’s perfectly reasonable to have row versions that aren’t garbage collected. There’s also no way to force garbage collection to occur.
So this is just to clarify that there are situations where garbage collection may not occur, or may occur slowly.
The post goes on to discuss that long-running queries on in-memory tables will completely block garbage collection, so make sure to check for any of those.
The reason the screenshot of SSMS is off (used it higher than allocated) is because it's purely based on the DMVs, so the NULL memory_allocated_for_table_kb throws off the calculation. This is what runs when you open the database properties window:
SELECT
isnull((
select convert(decimal(18,2),(sum(tms.memory_allocated_for_table_kb) + sum(tms.memory_allocated_for_indexes_kb)))
from [sys].[dm_db_xtp_table_memory_stats] tms)
, 0.00) AS [MemoryAllocatedToMemoryOptimizedObjectsInKB]
SELECT
isnull((
select convert(decimal(18,2),(sum(tms.memory_used_by_table_kb) + sum(tms.memory_used_by_indexes_kb)))
from [sys].[dm_db_xtp_table_memory_stats] tms)
, 0.00) AS [MemoryUsedByMemoryOptimizedObjectsInKB]
I'm still not really sure what the purpose of that object_id = 0 row is in dm_db_xtp_table_memory_stats. I can repeat the behavior locally (create a table with LOB data, then ALTER the column to fit in-row, suddenly I have that same 0 result), but I don't know if it's a problem.
It's possible that it's normal overhead related to in-memory OLTP, but it might be a bug. If it's causing significant problems, I'd suggest opening a case with Microsoft. There have been bugs before related to memory usage with LOB data, see MSDN Forums | In Memory OLTP for an example, and this CU: FIX: Out-of-memory error when you run a query to access LOB columns through In-Memory OLTP in SQL Server 2016.
I attached it the related image, I get it at database options in General tab.
– Ehsan HP
Dec 22 at 5:06
@Ehs thanks! You still haven't mentioned the query you're running to get the results in your first screenshot. Is it just selecting fromsys.dm_db_xtp_table_memory_stats, or are you joining to other tables / DMVs?
– jadarnel27
Dec 22 at 15:15
yeah, I get result from sys.dm_db_xtp_table_memory_stats ,
– Ehsan HP
Dec 23 at 6:10
add a comment |
You should check out this blog post from the king of In-Memory OLTP, Ned Otter:
Row version lifecycle for In-Memory OLTP
In particular, this passage:
2. Deallocating rows from memory
...
So the two triggers for Garbage Collection are memory pressure and/or transactional activity. Conversely, that means if there’s no memory pressure – or transactional activity is low – it’s perfectly reasonable to have row versions that aren’t garbage collected. There’s also no way to force garbage collection to occur.
So this is just to clarify that there are situations where garbage collection may not occur, or may occur slowly.
The post goes on to discuss that long-running queries on in-memory tables will completely block garbage collection, so make sure to check for any of those.
The reason the screenshot of SSMS is off (used it higher than allocated) is because it's purely based on the DMVs, so the NULL memory_allocated_for_table_kb throws off the calculation. This is what runs when you open the database properties window:
SELECT
isnull((
select convert(decimal(18,2),(sum(tms.memory_allocated_for_table_kb) + sum(tms.memory_allocated_for_indexes_kb)))
from [sys].[dm_db_xtp_table_memory_stats] tms)
, 0.00) AS [MemoryAllocatedToMemoryOptimizedObjectsInKB]
SELECT
isnull((
select convert(decimal(18,2),(sum(tms.memory_used_by_table_kb) + sum(tms.memory_used_by_indexes_kb)))
from [sys].[dm_db_xtp_table_memory_stats] tms)
, 0.00) AS [MemoryUsedByMemoryOptimizedObjectsInKB]
I'm still not really sure what the purpose of that object_id = 0 row is in dm_db_xtp_table_memory_stats. I can repeat the behavior locally (create a table with LOB data, then ALTER the column to fit in-row, suddenly I have that same 0 result), but I don't know if it's a problem.
It's possible that it's normal overhead related to in-memory OLTP, but it might be a bug. If it's causing significant problems, I'd suggest opening a case with Microsoft. There have been bugs before related to memory usage with LOB data, see MSDN Forums | In Memory OLTP for an example, and this CU: FIX: Out-of-memory error when you run a query to access LOB columns through In-Memory OLTP in SQL Server 2016.
I attached it the related image, I get it at database options in General tab.
– Ehsan HP
Dec 22 at 5:06
@Ehs thanks! You still haven't mentioned the query you're running to get the results in your first screenshot. Is it just selecting fromsys.dm_db_xtp_table_memory_stats, or are you joining to other tables / DMVs?
– jadarnel27
Dec 22 at 15:15
yeah, I get result from sys.dm_db_xtp_table_memory_stats ,
– Ehsan HP
Dec 23 at 6:10
add a comment |
You should check out this blog post from the king of In-Memory OLTP, Ned Otter:
Row version lifecycle for In-Memory OLTP
In particular, this passage:
2. Deallocating rows from memory
...
So the two triggers for Garbage Collection are memory pressure and/or transactional activity. Conversely, that means if there’s no memory pressure – or transactional activity is low – it’s perfectly reasonable to have row versions that aren’t garbage collected. There’s also no way to force garbage collection to occur.
So this is just to clarify that there are situations where garbage collection may not occur, or may occur slowly.
The post goes on to discuss that long-running queries on in-memory tables will completely block garbage collection, so make sure to check for any of those.
The reason the screenshot of SSMS is off (used it higher than allocated) is because it's purely based on the DMVs, so the NULL memory_allocated_for_table_kb throws off the calculation. This is what runs when you open the database properties window:
SELECT
isnull((
select convert(decimal(18,2),(sum(tms.memory_allocated_for_table_kb) + sum(tms.memory_allocated_for_indexes_kb)))
from [sys].[dm_db_xtp_table_memory_stats] tms)
, 0.00) AS [MemoryAllocatedToMemoryOptimizedObjectsInKB]
SELECT
isnull((
select convert(decimal(18,2),(sum(tms.memory_used_by_table_kb) + sum(tms.memory_used_by_indexes_kb)))
from [sys].[dm_db_xtp_table_memory_stats] tms)
, 0.00) AS [MemoryUsedByMemoryOptimizedObjectsInKB]
I'm still not really sure what the purpose of that object_id = 0 row is in dm_db_xtp_table_memory_stats. I can repeat the behavior locally (create a table with LOB data, then ALTER the column to fit in-row, suddenly I have that same 0 result), but I don't know if it's a problem.
It's possible that it's normal overhead related to in-memory OLTP, but it might be a bug. If it's causing significant problems, I'd suggest opening a case with Microsoft. There have been bugs before related to memory usage with LOB data, see MSDN Forums | In Memory OLTP for an example, and this CU: FIX: Out-of-memory error when you run a query to access LOB columns through In-Memory OLTP in SQL Server 2016.
You should check out this blog post from the king of In-Memory OLTP, Ned Otter:
Row version lifecycle for In-Memory OLTP
In particular, this passage:
2. Deallocating rows from memory
...
So the two triggers for Garbage Collection are memory pressure and/or transactional activity. Conversely, that means if there’s no memory pressure – or transactional activity is low – it’s perfectly reasonable to have row versions that aren’t garbage collected. There’s also no way to force garbage collection to occur.
So this is just to clarify that there are situations where garbage collection may not occur, or may occur slowly.
The post goes on to discuss that long-running queries on in-memory tables will completely block garbage collection, so make sure to check for any of those.
The reason the screenshot of SSMS is off (used it higher than allocated) is because it's purely based on the DMVs, so the NULL memory_allocated_for_table_kb throws off the calculation. This is what runs when you open the database properties window:
SELECT
isnull((
select convert(decimal(18,2),(sum(tms.memory_allocated_for_table_kb) + sum(tms.memory_allocated_for_indexes_kb)))
from [sys].[dm_db_xtp_table_memory_stats] tms)
, 0.00) AS [MemoryAllocatedToMemoryOptimizedObjectsInKB]
SELECT
isnull((
select convert(decimal(18,2),(sum(tms.memory_used_by_table_kb) + sum(tms.memory_used_by_indexes_kb)))
from [sys].[dm_db_xtp_table_memory_stats] tms)
, 0.00) AS [MemoryUsedByMemoryOptimizedObjectsInKB]
I'm still not really sure what the purpose of that object_id = 0 row is in dm_db_xtp_table_memory_stats. I can repeat the behavior locally (create a table with LOB data, then ALTER the column to fit in-row, suddenly I have that same 0 result), but I don't know if it's a problem.
It's possible that it's normal overhead related to in-memory OLTP, but it might be a bug. If it's causing significant problems, I'd suggest opening a case with Microsoft. There have been bugs before related to memory usage with LOB data, see MSDN Forums | In Memory OLTP for an example, and this CU: FIX: Out-of-memory error when you run a query to access LOB columns through In-Memory OLTP in SQL Server 2016.
edited 10 hours ago
answered Dec 20 at 12:22
jadarnel27
3,2801329
3,2801329
I attached it the related image, I get it at database options in General tab.
– Ehsan HP
Dec 22 at 5:06
@Ehs thanks! You still haven't mentioned the query you're running to get the results in your first screenshot. Is it just selecting fromsys.dm_db_xtp_table_memory_stats, or are you joining to other tables / DMVs?
– jadarnel27
Dec 22 at 15:15
yeah, I get result from sys.dm_db_xtp_table_memory_stats ,
– Ehsan HP
Dec 23 at 6:10
add a comment |
I attached it the related image, I get it at database options in General tab.
– Ehsan HP
Dec 22 at 5:06
@Ehs thanks! You still haven't mentioned the query you're running to get the results in your first screenshot. Is it just selecting fromsys.dm_db_xtp_table_memory_stats, or are you joining to other tables / DMVs?
– jadarnel27
Dec 22 at 15:15
yeah, I get result from sys.dm_db_xtp_table_memory_stats ,
– Ehsan HP
Dec 23 at 6:10
I attached it the related image, I get it at database options in General tab.
– Ehsan HP
Dec 22 at 5:06
I attached it the related image, I get it at database options in General tab.
– Ehsan HP
Dec 22 at 5:06
@Ehs thanks! You still haven't mentioned the query you're running to get the results in your first screenshot. Is it just selecting from
sys.dm_db_xtp_table_memory_stats, or are you joining to other tables / DMVs?– jadarnel27
Dec 22 at 15:15
@Ehs thanks! You still haven't mentioned the query you're running to get the results in your first screenshot. Is it just selecting from
sys.dm_db_xtp_table_memory_stats, or are you joining to other tables / DMVs?– jadarnel27
Dec 22 at 15:15
yeah, I get result from sys.dm_db_xtp_table_memory_stats ,
– Ehsan HP
Dec 23 at 6:10
yeah, I get result from sys.dm_db_xtp_table_memory_stats ,
– Ehsan HP
Dec 23 at 6:10
add a comment |
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f225447%2fmemory-optimized-table-memory-allocated-issues%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown