SQL Server Performance

Memory leakage in SQL Server 2005

Discussion in 'SQL Server 2005 General Developer Questions' started by MSSQLUser, Apr 5, 2010.

  1. MSSQLUser New Member

    <p>Hi, I have a client application that basically looks similar to the one following :-<br></p><div id="KonaBody"><div id="post_message_6455095"><br>import java.sql.Connection;<br>import java.sql.DriverManager;<br>import java.sql.ResultSet;<br>import java.sql.SQLException;<br>import java.sql.Statement;<br><br>public class LoadSQLServer {<br> Connection connection;<br><br> private void displaySQLErrors(SQLException e) {<br> e.printStackTrace();<br><br> }<br><br> public LoadSQLServer() {<br> try {<br> Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");<br> } catch (Exception e) {<br> e.printStackTrace();<br> }<br> }<br><br> public void connectToDB(String db_connect_string,<br> String db_userid, String db_password) {<br> try {<br> connection = DriverManager.getConnection(<br> db_connect_string, db_userid, db_password);<br> System.out.println("Connection is successful"+connection);<br> } catch (SQLException e) {<br> displaySQLErrors(e);<br> }<br>}<br><br> public void executeSQL() {<br> try {<br> <br> String lastTS="2010-03-24 02:17:40.793";<br> while (true) {<br> Statement statement = connection.createStatement();<br> String query = "select * from fn_trace_gettable('C:path',default) where StartTime &gt;"+"'"+lastTS+"'";<br> ResultSet rs = statement.executeQuery(query);<br> while (rs.next()) {<br> lastTS = rs.getString("StartTime");<br> }<br> rs.close();<br> statement.close();<br> Thread.sleep(4000L);<br> }<br> }catch (SQLException e) {<br> displaySQLErrors(e);<br><br> } catch (Exception e) {<br> e.printStackTrace();<br> }<br>}<br><br> public static void main(String[] args) {<br> LoadSQLServer hello = new LoadSQLServer();<br> hello.connectToDB("jdbc:sqlserver://ip:port","username","pwd");<br> hello.executeSQL();<br> }<br>}<br><br><br>When this program is executed, the memory taken by the SQL Serverprocess starts increasing in a linear fashion and it continues to growwithout stabilising at any point. Please let me know why is there amemory leakage. Is this a bug in SQL Server and if it is then is itdocumented ? Otherwise what am I doing wrong that is making SQL Serverleak memory ?</div></div><!-- / message --> <!-- controls --> <img src="http://www.dbforums.com/db_images_v3/images/misc/progress.gif" style="display: none;" id="progress_6455095" alt=""><a href="http://www.dbforums.com/editpost.php?do=editpost&amp;p=6455095" class="" rel="nofollow" name="vB::QuickEdit::6455095"><img src="http://www.dbforums.com/db_images_v3/images/buttons/edit.gif" title="Edit/Delete Message" alt="Edit/Delete Message" border="0"></a>
  2. MohammedU New Member

    From SQL 2005 onwards, it takes memory as needed even if you configure the sql server memory setting (MAX SERVER MEMORY) to highier value...
    When you are running the app, SQL is using the memory...the behaviour is expected and it is not memory leak.
    If your server crashing during this app run?
  3. taha.amin New Member

    what is fn_trace_gettable?
  4. venkatesanj@hcl.in New Member

  5. satya Moderator

    What is the service pack level on SQL Server?

Share This Page