在中,我运行一个复杂的SELECT语句,运行时间为10分钟。它消耗我们服务器中的10 It内存。问题是当SELECT语句完成时,它不会释放内存。我们可以将MAX服务器内存设置为特定的内存,但我们想要的是它可以消耗服务器中所有可用的内存,当它处理完该进程时,它应该释放内存。
我相信这是内存泄漏,但我不能相信SQL SERVER中存在这样的问题。有什么解释吗?
发布于 2014-11-26 09:29:07
限制这一点的唯一方法是设置最大内存。这不是内存泄漏。这是Server的工作方式。它使用内存作为缓存。
如果您认为SQL server经常运行在专用服务器上,这并不是错误的。
我没有试过,但问题是,即使也不会释放您的内存(这是危险的)。
发布于 2014-11-26 09:22:06
当查询Server时,它会将数据页中的信息读取到缓冲区缓存中,以便以后的读取可以直接进入内存,并避免磁盘读取:这就是设计。要找出缓冲区缓存中的内容,并确认这是您所看到的内容的原因,您可以发出:
select
count(*)as cached_pages_count,
obj.name as objectname,
ind.name as indexname,
obj.index_id as indexid
from sys.dm_os_buffer_descriptors as bd
inner join
(
select object_id as objectid,
object_name(object_id) as name,
index_id,allocation_unit_id
from sys.allocation_units as au
inner join sys.partitions as p
on au.container_id = p.hobt_id
and (au.type = 1 or au.type = 3)
union all
select object_id as objectid,
object_name(object_id) as name,
index_id,allocation_unit_id
from sys.allocation_units as au
inner join sys.partitions as p
on au.container_id = p.partition_id
and au.type = 2
) as obj
on bd.allocation_unit_id = obj.allocation_unit_id
left outer join sys.indexes ind
on obj.objectid = ind.object_id
and obj.index_id = ind.index_id
where bd.database_id = db_id()
and bd.page_type in ('data_page', 'index_page')
group by obj.name, ind.name, obj.index_id
order by cached_pages_count desc发布于 2014-11-26 09:21:45
SQL server倾向于占用配置的最大内存的所有可用内存,然后才将部分内存释放给自己。我发现的“处理此问题”的唯一方法是将最大内存设置为我希望引擎使用的最大数量。
https://stackoverflow.com/questions/27145197
复制相似问题