dbTalk Databases Forums  

Memory leak in SQL Server

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Memory leak in SQL Server in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bardolator
 
Posts: n/a

Default Memory leak in SQL Server - 05-10-2005 , 05:33 PM






I have a stand alone Java application that uses MS SQL Server 2000 and
Microsoft JDBC ODBC drivers to access it. Before I run the application,
I open the task Manager to monitor the memory used by the SQL Server.
Generally it begins 21 MB and very soon it reaches around 100 MB if I
do some operations in the application. The thing is that even if I
close the application, the memory taken by SQL Server doesn't go down.
What could be the reason behind it? Java code or MD drivers or SQL
Server?
I checked the code and we are closing the statements and result set and
commiting everywhere.

Please let me know...I am trying to refactor as much as I can but still
out of luck.


Reply With Quote
  #2  
Old   
Gang He [MSFT]
 
Posts: n/a

Default Re: Memory leak in SQL Server - 05-10-2005 , 07:20 PM






It is not a memory leak. It is most likely due to the buffer pool growth.
When the server is started, buffer pool reserves a lot of memory but not
committed. The buffer page memory is committed only one-by-one upon demand
when the app issues queries to read/write data. TaskMgr only shows the
committed memory, which is why you saw the memory used by sqlservr
increased. And once the buffer page memory is committed, normally buffer
pool doesn't give them back unless under memory pressure. This is why after
the app ends, the memory used by sqlservr in TaskMgr doesn't go down.

Other usage of memory in the server can also contribute here: for example,
the query plans used by the app can be cached by the procedure cache for
furure usage, etc.

--
Gang He
Software Design Engineer
Microsoft SQL Server Storage Engine

This posting is provided "AS IS" with no warranties, and confers no rights.
"Bardolator" <Bardolator (AT) gmail (DOT) com> wrote

Quote:
I have a stand alone Java application that uses MS SQL Server 2000 and
Microsoft JDBC ODBC drivers to access it. Before I run the application,
I open the task Manager to monitor the memory used by the SQL Server.
Generally it begins 21 MB and very soon it reaches around 100 MB if I
do some operations in the application. The thing is that even if I
close the application, the memory taken by SQL Server doesn't go down.
What could be the reason behind it? Java code or MD drivers or SQL
Server?
I checked the code and we are closing the statements and result set and
commiting everywhere.

Please let me know...I am trying to refactor as much as I can but still
out of luck.




Reply With Quote
  #3  
Old   
Bardolator
 
Posts: n/a

Default Re: Memory leak in SQL Server - 05-10-2005 , 10:12 PM



If that is the thing then is there a way to keep the memory of SQL
server down? Any settings in the SQL server or any code to clear the
buffer? The reason is that if the machine or SQL server isn't started
for few days on a machine, SQL server tends to take more than 200 MB of
memory which slows down the computer.
(Wonder why no one else complains of this memory issue on the net)


Reply With Quote
  #4  
Old   
rudianus
 
Posts: n/a

Default Re: Memory leak in SQL Server - 05-10-2005 , 11:10 PM



The amount of memory used by sql 2000 is definable. Enterprise
mgr>right mouse properties on server in question>memory tab.

No one complains because it is not a problem. Caching selected
data/procedure plans/etc... is a good thing in databases.

-scott


Reply With Quote
  #5  
Old   
Greg D. Moore \(Strider\)
 
Posts: n/a

Default Re: Memory leak in SQL Server - 05-10-2005 , 11:24 PM




"Bardolator" <Bardolator (AT) gmail (DOT) com> wrote

Quote:
If that is the thing then is there a way to keep the memory of SQL
server down? Any settings in the SQL server or any code to clear the
buffer? The reason is that if the machine or SQL server isn't started
for few days on a machine, SQL server tends to take more than 200 MB of
memory which slows down the computer.
(Wonder why no one else complains of this memory issue on the net)
Because you want to give a DB server as much memory as possible.

My guess is that you're not running on a dedicated machine?

Add memory if at all possible.


Quote:



Reply With Quote
  #6  
Old   
Robert Klemme
 
Posts: n/a

Default Re: Memory leak in SQL Server - 05-11-2005 , 04:45 AM



Bardolator wrote:
Quote:
If that is the thing then is there a way to keep the memory of SQL
server down? Any settings in the SQL server or any code to clear the
buffer? The reason is that if the machine or SQL server isn't started
for few days on a machine, SQL server tends to take more than 200 MB
of memory which slows down the computer.
(Wonder why no one else complains of this memory issue on the net)
Even if it takes 200MB this is not a problem as long as the DB is not
used. The OS will evetually page out unused mem to disk. You might want
to increase virtual memory.

Alternatively you can decrease memory settings for SQL Server but this
impacts the DB's performance.

OTOH, 200MB isn't really much for a DB. Buying some additional mem is not
a bad idea.

Kind regards

robert



Reply With Quote
  #7  
Old   
Bardolator
 
Posts: n/a

Default Re: Memory leak in SQL Server - 05-11-2005 , 10:30 AM



This is a stand alone java application using the stand alone sql server
(actually MSDE for the end users) that is resident on their PCs. So 200
MB is a lot if only one user is connected to it. I will try to change
the settings and will see what happens.


Reply With Quote
  #8  
Old   
Robert Klemme
 
Posts: n/a

Default Re: Memory leak in SQL Server - 05-11-2005 , 10:48 AM



Bardolator wrote:
Quote:
This is a stand alone java application using the stand alone sql
server (actually MSDE for the end users) that is resident on their
PCs. So 200 MB is a lot if only one user is connected to it. I will
try to change the settings and will see what happens.
It does seem much to you - it doesn't to me. :-)

Note also that the memory usage is mainly determined by the amount of data
you touch and not by the sheer number of users.

Kind regards

robert



Reply With Quote
  #9  
Old   
Bardolator
 
Posts: n/a

Default Re: Memory leak in SQL Server - 05-11-2005 , 11:51 AM



But I thought that the whole point of having a scale down version of
SQL Server (which is MSDE) is that it can be installed on individual
PCs. Also, MSDE 1.0 (which is the scale down version of SQL Server 7.0)
did not take this much of memory.


Reply With Quote
  #10  
Old   
Malcolm
 
Posts: n/a

Default Re: Memory leak in SQL Server - 05-12-2005 , 04:14 AM



Is there actually a real problem with the performance of your
application or are you just curious about the memory usage of SQL
Server?

It is always better to make questions clearer as they elicit more
specific responses.

i.e. the subject of the internal workings of SQL Server and Windows
virtual memory allocation could take a great many posts to explain and
you would probably be better off reading books such as Inside SQL
Server or The Gurus Guide To SQL Server Architecture and Internals.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.