views:

324

answers:

0

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;
        }
    }