11

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?

2
  • How are you measuring these figures? Bear in mind that task manager can give figures which are misleading (I'd always opt for perfmon, and look at the private/virtual bytes) May 13, 2009 at 7:45
  • I am monitoring the sql sever using task manager and separate dotnet application that uses PerformanceCounter class
    – Ahmed
    May 13, 2009 at 8:25

4 Answers 4

27

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.

4

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:

EXEC sys.sp_configure N'show advanced options', N'1'

RECONFIGURE WITH OVERRIDE

GO

EXEC sys.sp_configure N'max server memory (MB)', N'{low water mark}'

GO

RECONFIGURE WITH OVERRIDE

GO

EXEC sys.sp_configure N'max server memory (MB)', N'{High water mark}'

GO

RECONFIGURE WITH OVERRIDE

GO

EXEC sys.sp_configure N'show advanced options', N'0'

RECONFIGURE WITH OVERRIDE

GO

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.

1

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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.