ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

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.

https://github.com/unvell/ReoGrid/issues

#1 2015-01-12 03:38:00

xy
Member
Registered: 2015-01-12
Posts: 1

Memory leak occurs in 0.8.8

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

#2 2015-01-13 05:21:03

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Memory leak occurs in 0.8.8

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

Board footer

Powered by FluxBB