Home > Net >  C # memory increases in the assignment
C # memory increases in the assignment

Time:11-21

When using this function, the last sentence comobox.Com boBox1. SelectedIndex=curIdx; After the operation, the memory process in task manager increases, this GetControlFromDic function from a dictionary found incoming parameters corresponding controls, then returned and have a great god solve?????? Why the last assignment statements will lead to increase memory?
Private void ResetNumSlGrp (int total, int curIdx)
{
The object tt=GetControlFromDic (" num_sl_grp ");
If (tt!=null)
{
BtnComobox comobox=tt as BtnComobox;
Comobox.Com boBox1. Items. The Clear ();
For (int I=1; i {
Comobox.Com boBox1. Items. The Add (i.T oString ());
}
Comobox.Com boBox1. SelectedIndex=curIdx;
}
}

CodePudding user response:

Detail also can ask, where is the big!

CodePudding user response:

The ComboBox1 project cycle added project, you will need to save exists inside, increase until the last sentence you said, is delayed, comobox.Com boBox1. Items. The Add (i.T oString ()); This sentence should be increased,

CodePudding user response:

Emmm I didn't say clear, the problem is that the function after the operation, the memory has been on the rise, this function if frequent calls, will result in system memory and then collapse,,,

CodePudding user response:

Are you haven't released a resource in the code? The object tt=GetControlFromDic (" num_sl_grp "); May be related to this in the code

CodePudding user response:

You can put the object tt=GetControlFromDic (" num_sl_grp "); This line at the back of the statement is blocked, perform a while to see whether the same more memory, so is the problem in this code, the code behind the looks no problem
  •  Tags:  
  • C#
  • Related