Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Posts
    2

    Unanswered: Memory leakage in SQL Server 2005

    Hi, I have a client application that basically looks similar to the one following :-

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;

    public class LoadSQLServer {
    Connection connection;

    private void displaySQLErrors(SQLException e) {
    e.printStackTrace();

    }

    public LoadSQLServer() {
    try {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    public void connectToDB(String db_connect_string,
    String db_userid, String db_password) {
    try {
    connection = DriverManager.getConnection(
    db_connect_string, db_userid, db_password);
    System.out.println("Connection is successful"+connection);
    } catch (SQLException e) {
    displaySQLErrors(e);
    }
    }

    public void executeSQL() {
    try {

    String lastTS="2010-03-24 02:17:40.793";
    while (true) {
    Statement statement = connection.createStatement();
    String query = "select * from fn_trace_gettable('C:\path',default) where StartTime >"+"'"+lastTS+"'";
    ResultSet rs = statement.executeQuery(query);
    while (rs.next()) {
    lastTS = rs.getString("StartTime");
    }
    rs.close();
    statement.close();
    Thread.sleep(4000L);
    }
    }catch (SQLException e) {
    displaySQLErrors(e);

    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    public static void main(String[] args) {
    LoadSQLServer hello = new LoadSQLServer();
    hello.connectToDB("jdbc:sqlserver://iport","username","pwd");
    hello.executeSQL();
    }
    }


    When this program is executed, the memory taken by the SQL Server process starts increasing in a linear fashion and it continues to grow without stabilising at any point. Please let me know why is there a memory leakage. Is this a bug in SQL Server and if it is then is it documented ? Otherwise what am I doing wrong that is making SQL Server leak memory ?

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    What leads you to think:
    Quote Originally Posted by MSSQLUser View Post
    When this program is executed, the memory taken by the SQL Server process starts increasing in a linear fashion and it continues to grow without stabilising at any point.
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Mar 2010
    Posts
    2
    It is observed on the task manager. Moreover, our concern is that the server is used for many other purposes. It should not be taking so much memory for a simple client application.

    Upon startup of SQL Services, the server's memory usage was around 50 MB. As soon as I start this process, within a few minutes, the memory usage increases upto 200 MB and is continuing to grow. At that point I terminated the process.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •