Hi,
I'm populating an ultragrid.datasource with a datatable. I've got on the InitializeRow event a method that inserts an image on certain column. I've got a button that after clicked return new datatable and it substitue the ultragrid.datasource. The problem is that each time that the ultragrid.datasource has other datatable the memory increases all the time, until the program launch an exception of memory usage.
I've already tried ultragrid.datasource = null before setting the new datatable. Tried:
ultragrid.DisplayLayout.Reset();ultragrid.Layouts.Clear();
Nothing works. It seems that the grid is saving old sources. How could i clear it?
fzenha said:I don´t have any datatable object,
So you are calling a method that probably creates a new DataTable and assigns it directly to the DataSource of the grid and you are therefore never disposing of that DataTable. You should store the DataTable in a variable or get it from the grid and dispose it when you don't need it any more.
Even if i take off the images every time i refresh the grid the memory usage increases. Increases slower but still increase and after a while the application blows because of that. Is there something else i should dispose after refreshing datasource of the grid? I don´t have any datatable object, i return directly from database to datasource like this: grid.DataSource = AccountService( ).GetTasksDT( );
One thing to note is that the DataTable is a disposable object, and if you don't explicitly call it Dispose method, it can stay in memory for an indeterminate period of time. Also, if something else is holding a reference to it, the garbage collector will not grab it so the memory will not be released.
Another thing to note is that images are also disposable objects, so you might need to explicitly dispose of them as well.
Since you mentioned the images, does that mean if you do not add in the images to the grid that the problem does not occur?
How, exactly are you getting your images and how are you applying them to the grid? My guess is that you are not disposing of the image objects you create. But that's just a guess, since I don't know how you are getting or using your images.
Also, what version of the grid are you using?