SQL 2008 SMO Database Status property memory leak.

Posted by AKoran on Stack Overflow See other posts from Stack Overflow or by AKoran
Published on 2009-01-09T15:16:29Z Indexed on 2010/03/15 2:49 UTC
Read the original article Hit count: 501

Filed under:
|
|
|

It appears there is a memory leak in the Status property of the SMO Database class.

Using the code below with SQL 2005 SMO libraries works fine, but as soon as you use SQL 2008, the memory leak appears....

Any other good way of getting the database staus in SQL 2008?

A quick example that magnifies the problem:

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        for (int x = 0; x < 100; x++)
        {
            CheckStatus();
        }
    }

    private void CheckStatus()
    {
        Server server = new Server("YourServer");
        DatabaseCollection dbc = server.Databases;
        if (dbc.Contains("YourDatabase"))
        {
            DatabaseStatus dbStatus = dbc["YourDatabase"].Status;
        }
    }

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about c#