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
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