Home > Forefront TMG 2010, Threat Management Gateway > Configuring SQL Memory Limits on Forefront TMG 2010

Configuring SQL Memory Limits on Forefront TMG 2010

When Forefront TMG 2010 is installed, an instance of SQL Server 2008 Express is also installed to facilitate local firewall and web proxy logging. Some TMG administrators have reported that the SQL server process (sqlservr.exe) may consume an excessive amount of memory.

This occurs because SQL server performs its own internal memory management. By design it will consume large amounts of memory and hold it in reserve, which may appear to be a memory leak. However, if you observe the memory consumed by SQL server over an extended period of time, you will notice that it will periodically release memory as well.

In most cases, allowing SQL to handle the job of managing its memory without restriction poses no real problem. However, if your system is exhibiting signs of high memory pressure and you are confident that there are no other processes that are consuming excessive amounts of memory, you can configure SQL to limit the amount of memory that it will reserve. Before manually configuring SQL memory limits, review this blog post for a list of recommended settings.

Next, open an elevated command prompt and enter the following command:

osql –E –S .\msfw

After connecting to the SQL instance, enter the following commands:

USE master
GO

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

EXEC sp_configure 'max server memory (MB)', 1024 --configure 1GB limit, adjust as needed
GO

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

This script assumes that you’ve chosen a 1GB (1024MB) memory limit. You can adjust the script above to reflect the values for your environment as required. Once complete, restart the SQL server service for the changes to take effect.

To view the currently configured memory limit, simply omit the numeric value after max server memory (MB), as shown here:

EXEC sp_configure 'max server memory (MB)'

To make things easier you can download these as script files and execute them using the following command:

osql –E –S .\msfw -i <path to script file>

You can find script files to show and set SQL memory limits here:

showsqlmem.sql
setsqlmem.sql

  1. January 23, 2012 at 9:58 am | #1

    Good tips. Most notice this when they move a SQL server to a virtualized environment. Memory allocated was perfectly calculated and right sized for the VM, then SQL sucks it all up like a vacuum. Linux also does this for file system operations as well, but that is a whole other topic.

    Great SQL statements provided though. Thanks for sharing

  2. Vuk
    January 23, 2012 at 11:45 pm | #2

    Tnx for this, I’ve been looking for this.

  3. CHARO IT
    January 24, 2012 at 1:01 am | #3

    Dear Richard,

    Thank you for the post.

    Unfortunately, I am not able to open a connection to SQL Express instance, however Name Pipe is enabled.
    Please find below for more information:

    C:\Users\LAB>OSQL -E -S ./MSFW
    [SQL Server Native Client 10.0]Named Pipes Provider: Could not open a
    connection to SQL Server [3].
    [SQL Server Native Client 10.0]Login timeout expired
    [SQL Server Native Client 10.0]A network-related or instance-specific error
    has occurred while establishing a connection to SQL Server. Server is not
    found or not accessible. Check if instance name is correct and if SQL Server
    is configured to allow remote connections. For more information see SQL Server
    Books Online.

    Please advise.

    Thank you and regards,

  4. January 24, 2012 at 7:30 am | #4

    You are using the wrong slash. It should be .\msfw and not ./msfw. :)

  5. CHARO IT
    January 24, 2012 at 9:05 am | #5

    Thank you Richard :)

    It works great!

    Regards,

  6. Colin Golden
    January 25, 2012 at 5:44 am | #6

    Richard,

    I’ve a client using UAG2010 who perceived he has a memory leak as well.
    I assume the same SQL express instance is installed when UAG us used?

    If so, would it be safe to use the SQL commands on a UAG installation (It’s also an NLB array :( so I imagine you’d have to manually apply the script to each array member.)

    Thanks in advance,

    Colin

  7. January 25, 2012 at 9:45 am | #7

    Hi Colin,

    Absolutely. Forefront TMG 2010 is installed when UAG 2010 is installed, so this script will function in exactly the same way on a UAG server.

  1. February 8, 2012 at 4:57 pm | #1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 35 other followers