SQL Server中的内存泄漏 [英] Memory leak in SQL Server

查看:87
本文介绍了SQL Server中的内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个独立的Java应用程序,它使用MS SQL Server 2000和

Microsoft JDBC ODBC驱动程序来访问它。在我运行应用程序之前,

我打开任务管理器来监视SQL Server使用的内存。

一般它开始21 MB,很快就会达到100 MB左右如果我

在应用程序中执行某些操作。问题是,即使我关闭了应用程序,SQL Server占用的内存也不会下降。

背后的原因是什么? Java代码或MD驱动程序或SQL

服务器?

我检查了代码,我们正在关闭语句和结果集,并且

在任何地方提交。


请让我知道......我试图尽可能地重构但仍然没有好运。

解决方案

这不是内存泄漏。这很可能是由于缓冲池的增长。

当服务器启动时,缓冲池会保留大量内存,但不会提交
。当应用程序发出读/写数据查询时,缓冲页面内存仅在需要时逐个提交

。 TaskMgr只显示

提交的内存,这就是为什么你看到sqlservr

使用的内存增加了。一旦提交缓冲区页面内存,通常缓冲区

池除非受到内存压力,否则不会回复它们。这就是为什么在应用程序结束之后,sqlservr在TaskMgr中使用的内存不会消失。


服务器中内存的其他用法可以在这里也有所贡献:例如,

应用程序使用的查询计划可以通过程序缓存进行缓存,用于

福利用法等。

-

Gang He

软件设计工程师

Microsoft SQL Server存储引擎


此帖子按原样提供。没有保证,也没有赋予任何权利。

Bardolator <巴******** @ gmail.com>在消息中写道

news:11 ********************** @ f14g2000cwb.googlegr oups.com ...

我有一个独立的Java应用程序,它使用MS SQL Server 2000和Microsoft JDBC ODBC驱动程序来访问它。在我运行应用程序之前,我打开任务管理器来监视SQL Server使用的内存。
一般来说它开始是21 MB,如果我做了一些,它很快就会达到100 MB左右应用程序中的操作。问题是,即使我关闭应用程序,SQL Server占用的内存也不会消失。
背后的原因是什么? Java代码或MD驱动程序或SQL
服务器?
我检查了代码,我们正在关闭语句和结果集并且
在任何地方提交。

请让我知道......我试图尽可能地重构但仍然没有运气。



如果那就是那件事那么就在那里一种保持SQL内存的方法

服务器关闭? SQL服务器中的任何设置或任何清除

缓冲区的代码?原因是,如果机器或SQL服务器在一台机器上没有启动几天,那么SQL服务器往往需要超过200 MB的内存。减慢了电脑的速度。

(不知道为什么没有人在网上抱怨这个内存问题)


金额sql 2000使用的内存是可定义的。企业

mgr>有问题的服务器上的鼠标右键属性>内存选项卡。


没人抱怨,因为这不是问题。选择缓存

数据/程序计划/等......在数据库中是一件好事。


-scott


I have a stand alone Java application that uses MS SQL Server 2000 and
Microsoft JDBC ODBC drivers to access it. Before I run the application,
I open the task Manager to monitor the memory used by the SQL Server.
Generally it begins 21 MB and very soon it reaches around 100 MB if I
do some operations in the application. The thing is that even if I
close the application, the memory taken by SQL Server doesn''t go down.
What could be the reason behind it? Java code or MD drivers or SQL
Server?
I checked the code and we are closing the statements and result set and
commiting everywhere.

Please let me know...I am trying to refactor as much as I can but still
out of luck.

解决方案

It is not a memory leak. It is most likely due to the buffer pool growth.
When the server is started, buffer pool reserves a lot of memory but not
committed. The buffer page memory is committed only one-by-one upon demand
when the app issues queries to read/write data. TaskMgr only shows the
committed memory, which is why you saw the memory used by sqlservr
increased. And once the buffer page memory is committed, normally buffer
pool doesn''t give them back unless under memory pressure. This is why after
the app ends, the memory used by sqlservr in TaskMgr doesn''t go down.

Other usage of memory in the server can also contribute here: for example,
the query plans used by the app can be cached by the procedure cache for
furure usage, etc.

--
Gang He
Software Design Engineer
Microsoft SQL Server Storage Engine

This posting is provided "AS IS" with no warranties, and confers no rights.
"Bardolator" <Ba********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

I have a stand alone Java application that uses MS SQL Server 2000 and
Microsoft JDBC ODBC drivers to access it. Before I run the application,
I open the task Manager to monitor the memory used by the SQL Server.
Generally it begins 21 MB and very soon it reaches around 100 MB if I
do some operations in the application. The thing is that even if I
close the application, the memory taken by SQL Server doesn''t go down.
What could be the reason behind it? Java code or MD drivers or SQL
Server?
I checked the code and we are closing the statements and result set and
commiting everywhere.

Please let me know...I am trying to refactor as much as I can but still
out of luck.



If that is the thing then is there a way to keep the memory of SQL
server down? Any settings in the SQL server or any code to clear the
buffer? The reason is that if the machine or SQL server isn''t started
for few days on a machine, SQL server tends to take more than 200 MB of
memory which slows down the computer.
(Wonder why no one else complains of this memory issue on the net)


The amount of memory used by sql 2000 is definable. Enterprise
mgr>right mouse properties on server in question>memory tab.

No one complains because it is not a problem. Caching selected
data/procedure plans/etc... is a good thing in databases.

-scott


这篇关于SQL Server中的内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆