且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server没有释放内存

更新时间:2023-02-02 07:58:22

实际上,一旦SQL Server抢占了内存,它就不会释放内存.我写了一个小脚本来释放内存.但是,您不应在繁忙的服务器上运行它.

512号可以更改为较小的数字,但是请注意,因为数字太低可能会使服务器崩溃.



USE管理员

EXEC sp_configure``显示高级选项'',1
重新配置以覆盖

EXEC sp_configure``最大服务器内存(MB)''

EXEC sp_configure``最大服务器内存(MB)'',512
重新配置以覆盖

EXEC sp_configure``最大服务器内存(MB)''

WAITFOR DELAY''00:00:15'';

EXEC sp_configure``最大服务器内存(MB)'',2147483647
重新配置以覆盖

EXEC sp_configure``最大服务器内存(MB)''

EXEC sp_configure``显示高级选项'',0
重新配置以覆盖


-Thomas Ross,pikitfense,当时是点点com
Actually SQL server does not release memory when once it grabs ahold of it. I have written a little script that I use to release memory. However you should NOT run this on a busy server.

the 512 number can be changed to a lower number but be careful as you might crash your server with too low of a number.



USE master

EXEC sp_configure ''show advanced options'', 1
RECONFIGURE WITH OVERRIDE

EXEC sp_configure ''max server memory (MB)''

EXEC sp_configure ''max server memory (MB)'', 512
RECONFIGURE WITH OVERRIDE

EXEC sp_configure ''max server memory (MB)''

WAITFOR DELAY ''00:00:15'';

EXEC sp_configure ''max server memory (MB)'', 2147483647
RECONFIGURE WITH OVERRIDE

EXEC sp_configure ''max server memory (MB)''

EXEC sp_configure ''show advanced options'', 0
RECONFIGURE WITH OVERRIDE
go

-Thomas Ross, pikitfense at h o t m a i l dot com


我不了解MFC.但是,您可以检查是否正确关闭/布置了连接对象吗?另外,您是否考虑过考虑ConnectionPooling?
I don''t know MFC. But, can you check if you are properly closing/disposing the connection objects? Also, have you thought of considering ConnectionPooling?


它还取决于您用来连接SQL Server的驱动程序.
请使用SQL Server OLE db驱动程序和连接器.
由于分配和释放内存对象非常灵活.

它还取决于您使用了哪种方法从SQL Server中提取数据.

我怀疑您应该使用存储过程并从您的代码中调用该SP.

请避免循环遍历记录集.
如果您设置一个射击活动,那就太好了.
Its also depend upon what driver you have used to connect the SQL server.
Please use SQL server OLE db driver and connector .
Since it is very flexible to allocate and releas memory objects.

It also depends upon what method you have used to pull out data from SQL server.

I suspect you should use Stored procedure and call that SP from within your code.

Please avoid looping thoruhg the record set .
It would be very nice if you set up one shot activity.