EasyXLS
http://forum.easyxls.com/

Problems with disposing of EasyXLS objects
http://forum.easyxls.com/viewtopic.php?f=9&t=1252
Page 1 of 1

Author:  timirish [ Fri Jul 10, 2009 3:34 am ]
Post subject:  Problems with disposing of EasyXLS objects

Good day to everyone.

I am having dificulties using EasyXLS 6.1 in my C# projects. I would like you to provide an exact procedure for disposing memory of your ExcelDocument object. The problem which I encounter is quite simple as that I have a feeling that memory is not cleared after calling Dispose method of ExcelDocument object

What I mean is:
///////////////////////////////////////////////////////
ExcelDocument xls = new ExcelDocument();
xls.easy_LoadXLSFile( stream );

// doing something with ExcelDocument, ExcelTable, ExcelCell etc...

xls.Dispose()
////////////////////////////////////////////////////////

The memory is not cleared after the last line of code above.

Thanks in advance!

Author:  daniela [ Fri Jul 10, 2009 6:21 am ]
Post subject: 

The memory is not clean each time when an object is disposed. .NET Framework uses an optimized algorithm for releasing memory. You may force the Garbage Collector to deallocate unused memory, using the System.GC.Collect() method. But this does not guarantee that the memory will be release for sure. If enough memory will be available, the memory will not be released at all.

Author:  timirish [ Fri Jul 10, 2009 6:33 am ]
Post subject: 

Daniela wrote:
The memory is not clean each time when an object is disposed. .NET Framework uses an optimized algorithm for releasing memory. You may force the Garbage Collector to deallocate unused memory, using the System.GC() method. But this does not guarantee that the memory will be release for sure. If enough memory will be available, the memory will not be released at all.


Thanks for a quick answer!

I understand all this perfectly well. I tried to call GC.Collect() explicitly but memory was not cleared. The real reason I asked this question is an exception trown by .net claiming "Out of memory" after loading 36M excel file. I would like to hear your suggestion on the issue.

Author:  daniela [ Fri Jul 10, 2009 6:56 am ]
Post subject: 

This depends on your computer performances. Your file is very big and it consumes at lot of memory when loading and more memory when writing, if this is the case.
Here is a post that contains one of our big volume tests :
http://forum.easyxls.com/viewtopic.php?t=1074

Author:  timirish [ Mon Jul 27, 2009 5:14 am ]
Post subject: 

Daniela wrote:
This depends on your computer performances. Your file is very big and it consumes at lot of memory when loading and more memory when writing, if this is the case.
Here is a post that contains one of our big volume tests :
http://forum.easyxls.com/viewtopic.php?t=1074


Thank you for information.
As I wrote above I would like you to provide an exact procedure for disposing memory of your ExcelDocument object. We really need it to make absolutely sure that we dispose all EasyXLS objects correctly.

Author:  daniela [ Tue Jul 28, 2009 4:25 am ]
Post subject: 

The only thing you can do is calling the System.GC.Collect() method.

Author:  timirish [ Wed Jul 29, 2009 7:32 am ]
Post subject: 

Daniela wrote:
The only thing you can do is calling the System.GC.Collect() method.


Thank you for a quick response.
As far as I understand you the desired procedure for disposing memory of all EasyXLS objects should be a simple one like this:

/////////////////////////////////////////////////////////////////////
ExcelDocument xls = new ExcelDocument();

// Doing something with ExcelDocument, ExcelTable, ExcelCell

xls.Dispose();
System.GC.Collect();
/////////////////////////////////////////////////////////////////////

Am I right?

Author:  daniela [ Wed Jul 29, 2009 7:34 am ]
Post subject: 

Right

Page 1 of 1 All times are UTC - 4 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/