Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1225
Searching for cells causes insane memory usage
posted

I am using 2009.1 w/the latest hotfixes.

I need loop through all my rows and find cells that match a value or a color.  At first I was doing ..

foreach (UltraGridRow aRow in gridConstraints.Rows)
{
 foreach(UltraGridCell aCell in aRow.Cells)
 {
  if(aCell.Appearance.BackColor == Color.Gray)
  {
   //do stuff
  }
 }
 
}

Each call to the the if statement cuased the memory to jump like crazy, after about 100 rows I am up to 1-1.5GB of memory usage.  So I thought maybe the Color.Gray was allocating some memory everytime so I thought I would try comparing a value.  The same problem happens...so I thought I would try this with LINQ like this..

foreach (UltraGridRow aRow in gridConstraints.Rows)
{

 List<UltraGridCell> cells = (from UltraGridCell c in aRow.Cells
  where c.Value == "X"
  select c).ToList();


 foreach (UltraGridCell aCell in cells)
 {
 }
 
 cells.Clear();
    cells = null;
}

...hoping the .Clear() and setting the list to null would clear the used RAM, but it is still using the same amount.

So my questions are why does doing a compare cause the memory to increase? How can I do this w/o the memory increasing or how can I release the used memory after each compare?

Parents Reply Children
No Data