SQL Server 2008占用大量内存?
我正在对我的数据库进行压力测试,该数据库托管在 SQL Server 2008 64 位上,在具有 10 GB RAM 的 64 位计算机上运行。
我有 400 个线程。 每个线程每秒都会查询数据库,但查询时间并不像 SQL 分析器所说的那样花费时间,但 18 小时后 SQL Server 使用了 7.2 GB RAM 和 7.2 GB 虚拟内存。
这是正常行为吗? 如何调整 SQL Server 来清理未使用的内存?
I am conducting stress tests on my database, which is hosted on SQL Server 2008 64-bit running on a 64-bit machine with 10 GB of RAM.
I have 400 threads. Each thread queries the database every second, but the query time does not take time, as the SQL profiler says that, but after 18 hours SQL Server uses up 7.2 GB of RAM and 7.2 GB of virtual memory.
Is this normal behavior? How can I adjust SQL Server to clean up unused memory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SQL Server 旨在使用尽可能多的内存,通过在内存中缓存大量内容来提高性能。 建议使用 SQL Server 专用机器,这使得这是一种完全有效的方法,因为它不希望其他任何人都需要内存。 所以你不应该担心这个; 这是完全正常的。
也就是说,如果您使用的是开发计算机而不是实时环境,您可能希望限制内存量以防止您的机器被接管。 这种情况最简单的方法是打开SQL Server Management Studio,右键单击服务器并选择“属性”,然后在“内存”选项卡上可以设置最大服务器内存。
SQL Server is designed to use as much memory as it can get its hands on, to improve performance by caching loads of stuff in memory. The recommendation is to use dedicated machines for SQL Server, which makes this a perfectly valid approach, as it isn't expecting anybody else to need the memory. So you shouldn't worry about this; it's perfectly normal.
That said, if you're on a development machine rather than a live environment, you may wish to limit the amount of memory to stop your box being taken over. In this case the easiest ways is to open SQL Server Management Studio, right-click on the server and select "Properties", then on the "Memory" tab you can set the maximum server memory.
事实上,有一个巧妙的小技巧可以帮助您找到所需的内容。 问题是如何让 SQL Server“暂时”放弃它可能不需要的内存,然后让它根据需要重新使用它。
为此,请运行以下脚本:
输入您自己的 {low water mark} 和 {high water mark} 值(以 MB 为单位)。
这将强制内存降至最小量,然后在 SQL Server 需要/需要时立即再次打开它。
剩下要做的唯一一件事就是安排脚本定期运行。
建议:
如果 SQL Server 使用率不高,请尝试每 6 小时自动运行一次。 如果使用频繁,请每 24 小时运行一次(例如在半夜或白天开始之前)。 您的使用情况会有所不同。
Actually, there's a neat little trick to get what you're looking for. The problem / question, is how to make SQL Server "temporarily" give up memory it may not agressively need, then let it reconsume it as required.
To do this , run the following script:
Put in your own values for {low water mark} and {high water mark} (in MB).
This'll force the memory down to a minimum amount, then open it again right away if SQL Server needs / wants it.
The only thing left to do, is schedule the script to run on a periodic basis.
Recommendation:
Where SQL Server isn't heavily used, try running this every 6 hours automatically. If it's heavily used, run once every 24 hours (say in the middle of the night or just before the day starts). Your usage will vary.
根据 Greg 的回答,当您配置内存时,请尝试为操作系统保留至少 10% 的可用内存。 如果 SQL 在长查询上失控,您希望该缓冲能够远程访问并仍然管理该框。
Going off Greg's answer, when you configure the memory try to leave at least 10% of the overall memory free for the OS. If SQL spins out of control on a long query you want that cushion to be able to remote in and still administrate the box.
http://support.microsoft.com/kb/961323
我认为这是一个解决方案问题。
它建议累积更新。
http://hotfixv4.microsoft.com /SQL%20Server%202008/nosp/SQL_Server_2008_Cumulative_Update_3/10.00.1787.00/free/370328_intl_x64_zip.exe
http://support.microsoft.com/kb/961323
I think this is a solution for this issue.
It recommends a cumulative update.
http://hotfixv4.microsoft.com/SQL%20Server%202008/nosp/SQL_Server_2008_Cumulative_Update_3/10.00.1787.00/free/370328_intl_x64_zip.exe