Click here to Skip to main content
15,885,960 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi every one

i made project in c# to save data in sql server data base "*.mdf"
the data i want to save text in about 10000 text files
so my project read each text file and save text in database
but i notice that when i run my project the memory which "sqlserver.exe" used increased to make save data very slow and the computer too

i used this code to save data in "*.mdf" file :
<pre lang="cs">public void NoReturnedValue(string commandstring)
        {
            //insert ,update,delete
            //open connection
            if (this.openconnection() == true)
            {
                //create command and assign the query and connection from the constructor
                SqlCommand cmd = new SqlCommand(commandstring, connection);
                //Execute command
                cmd.ExecuteNonQuery();
                //close connection
                this.closeconnection();
            }
        }



so how can i reduce to memory size which sqlsrver.exe taken???
i hope that i explaned my problem clearly
thanks all
Posted

1 solution

Open SQL management studio and connect to your SQL instance. Under object explorer, right click on the server name and choose properties - the 'Server Properties' dialog is shown

You can configure memory here, such as the minimum and maximum memory values allowed by SQL server

I think the defaults are min (0) and max (2147483647). This means SQL server will dynamically allocate itself memory when it is required.

http://technet.microsoft.com/en-us/library/ms181453.aspx[^]

"Use this page to view or modify your server memory options. When Minimum server memory is set to 0 and Maximum server memory is set to 2147483647, SQL Server can take advantage of the optimum amount of memory at any given time, subject to how much memory the operating system and other applications are currently using. As the load on the computer and SQL Server changes, so does the memory allocated. You can further limit this dynamic memory allocation to the minimum and maximum values specified below."

The thing to note is, even though SQL Server has allocated itself memory, it will release it to the OS 'on demand' if other applications require it.

If you don't have very much memory installed on the computer (say you are running SQL Sever, Visual Studio etc) then simply set a maximum value in the server memory config. This will limit the performance of SQL Server though.


In short, don't worry about SQL Server, it's pretty good at managing memory - worry about your own code!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900