You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Hi, Jing,
i like this control, but i found there is a memory leak when use it.
e.g, after run below code, the memory will increase about 6 MBs.
var grid = new ReoGridControl();
var sheet = grid.CurrentWorksheet;
int rows = 3000, cols = 10;
sheet.Resize(rows, cols);
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
sheet[i, j] = i * cols + j;
}
}
grid.Dispose();
or do i have a wrong use with it?
thank you.
Offline
Hi, Thanks!
I've tested this and confirmed that grid control didn't release memory before destroy. I will fix this in next release. Before that please use the following code instead:
var grid = new ReoGridControl();
var sheet = grid.CurrentWorksheet;
int rows = 3000, cols = 10;
sheet.Resize(rows, cols);
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
sheet[i, j] = i * cols + j;
}
}
sheet.Reset(); // clear worksheet
grid.Dispose();
The method Reset of worksheet will help to release the used memory, but since it also create some objects so a few memory will not be released.
After adding this method call, memory increasing 6MB will be decreased to about 400KB.
And sometimes, call the garbage collection of .NET Run-time to force release memory might also work.
GC.Collect(0, GCCollectionMode.Forced);
thanks, Jing
Offline