Memory Build Up

  • Thread starter Manjunath s via DotNetMonster.com
  • Start date
M

Manjunath s via DotNetMonster.com

Hi,
I am executing a set of semicoln sperated commands through ExecuteNonQuery,
the query length is about 10000 characters comprising of 200 repeated command
(identical command operating on different record ids). Each time the
ExecuteNonQuery is called the memory is increasing by few mega bytes. Since I
am executing the above in a loop the memory increase is significant and is
not reducing. I am ending up with almost 900mb of memory at the end of this
operation. What is the reason for this and is there any way to tackle this
problem.
I have pasted the code below

//mUpdateQuery is my orginal set of querys, here @mainNum is being replace by
mainNum value from the for loop
System.Text.StringBuilder conStr = new StringBuilder((mUpdateQuery.Length )*
200);
int i = 0, index = 1;
foreach(int mainNum in mainNums){//mainNums is a arraylist

i++;index++;
conStr.Append(mUpdateQuery+";");
conStr.Replace("@mainNum", mainNum.ToString());

if(i > 200){
i=0;
mCommandObj.CommandText = conStr.ToString();
mCommandObj.ExecuteNonQuery();
conStr.Remove(0, conStr.Length);
}

}

if(conStr.Length > 0){
mCommandObj.CommandText = conStr.ToString();
mCommandObj.ExecuteNonQuery();
}

Regards,
Manjunath
 
M

Miha Markic [MVP C#]

Hi,

Is build up of memory a problem for you - how much RAM dou you have?
Is disk swapping pages?
 
M

Manjunath s via DotNetMonster.com

Miha said:
Hi,

Is build up of memory a problem for you - how much RAM dou you have?
Is disk swapping pages?
Hi,
I am executing a set of semicoln sperated commands through
[quoted text clipped - 40 lines]
Regards,
Manjunath

Hi,
Thanks for the reply.
I have 512Mb of RAM, and build up of memory is a concern. The memory does
not seem to come down even after the closing of the application.
Regards,
Manjunath
 
M

Miha Markic [MVP C#]

Manjunath s via DotNetMonster.com said:
Miha said:
Hi,

Is build up of memory a problem for you - how much RAM dou you have?
Is disk swapping pages?
Hi,
I am executing a set of semicoln sperated commands through
[quoted text clipped - 40 lines]
Regards,
Manjunath

Hi,
Thanks for the reply.
I have 512Mb of RAM, and build up of memory is a concern.

Yup.

The memory does
not seem to come down even after the closing of the application.

This would suggest a non-.net problem at least not managed one.
Can you take a look at task manager to see who is actually eating the
memory?
It might be sql server...
 
M

Manjunath s via DotNetMonster.com

Miha said:
[quoted text clipped - 10 lines]
Thanks for the reply.
I have 512Mb of RAM, and build up of memory is a concern.

Yup.

The memory does
not seem to come down even after the closing of the application.

This would suggest a non-.net problem at least not managed one.
Can you take a look at task manager to see who is actually eating the
memory?
It might be sql server...
Regards,
Manjunath

Hi again,
The task manager showed the memory usage of sqlserv.exe to be around
224Mb when the stated operaton was running, the .net application itself
occupied around 94Mb at this point. When the operation completed sqlser.
exe's memory stood at 4Mb and .net Applications memory at 24Mb. However the
PF(Page File) usage was still around 962 Mb and there was no significant drop
even after closing the Application.

Rgds,
 
G

Guest

Manjunath s,

Be sure your memory usage measurements are accurate:

http://getdotnetco.web101.discountasp.net/GdncStore/free/Articles/The Memory Mystery.htm

http://www.itwriting.com/dotnetmem.php

http://groups.google.com/group/microsoft.public.dotnet.general/msg/392a8e932c39983d?hl=en

Kerry Moorman


Manjunath s via DotNetMonster.com said:
Miha said:
[quoted text clipped - 10 lines]
Thanks for the reply.
I have 512Mb of RAM, and build up of memory is a concern.

Yup.

The memory does
not seem to come down even after the closing of the application.

This would suggest a non-.net problem at least not managed one.
Can you take a look at task manager to see who is actually eating the
memory?
It might be sql server...
Regards,
Manjunath

Hi again,
The task manager showed the memory usage of sqlserv.exe to be around
224Mb when the stated operaton was running, the .net application itself
occupied around 94Mb at this point. When the operation completed sqlser.
exe's memory stood at 4Mb and .net Applications memory at 24Mb. However the
PF(Page File) usage was still around 962 Mb and there was no significant drop
even after closing the Application.

Rgds,
 
M

Manjunath s via DotNetMonster.com

Kerry said:


Hi,

I have gone through the links it gave a good insight into windows memory
management. I again checked my .net app and found it did not have any
problems. Sqlservr.exe was occupying most of the memory, its reading in Task
Manager read thus,
Mem Usage page faults VM Size
sqlservr.exe 9, 312k 349,414 525,136k

The VM Size was almost static for sql server, does this indicate
Memory leak. It is impacting overall system performance. Please suggest on
this matter.

Thanks,
Manjunath
 
M

Miha Markic [MVP C#]

Hi there,

AFAIK Sql server increases memory usage as needed and won't release it ever
(until you restart it or something like that).
You might limit sql server memory usage though (through EM for example).

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Manjunath s via DotNetMonster.com said:
Kerry said:


Hi,

I have gone through the links it gave a good insight into windows memory
management. I again checked my .net app and found it did not have any
problems. Sqlservr.exe was occupying most of the memory, its reading in
Task
Manager read thus,
Mem Usage page faults VM Size
sqlservr.exe 9, 312k 349,414 525,136k

The VM Size was almost static for sql server, does this indicate
Memory leak. It is impacting overall system performance. Please suggest
on
this matter.

Thanks,
Manjunath
 
M

Manjunath s via DotNetMonster.com

Miha said:
Hi there,

AFAIK Sql server increases memory usage as needed and won't release it ever
(until you restart it or something like that).
You might limit sql server memory usage though (through EM for example).
[quoted text clipped - 31 lines]
Thanks,
Manjunath

I am bit confused, should'nt sql server(or windows) release the memory
instead of windows throwing Virtual Memory error. Also, the cost of
unnecessary consumption of resources will affect the performance of other
applications. In the following link
http://groups.google.com/group/microsoft.public.dotnet.general/msg/392a8e932c39983d?hl=en

, the author says that any non release of Virtual Memory space would be
likely, leaking memory.
 
M

Miha Markic [MVP C#]

I am bit confused, should'nt sql server(or windows) release the
memory
instead of windows throwing Virtual Memory error. Also, the cost of
unnecessary consumption of resources will affect the performance of other
applications. In the following link
http://groups.google.com/group/microsoft.public.dotnet.general/msg/392a8e932c39983d?hl=en

, the author says that any non release of Virtual Memory space would be
likely, leaking memory.

AFAIK for Sql Server this behaviour is by design (not releasing memory).
Thus you should set the memory limit for sql server through one of its
configuration means.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top