Not Enough Memory to Start Excel

  • Thread starter Thread starter Elliot
  • Start date Start date
E

Elliot

The program loops through a dataset and creates several spreadsheets
based on a change in a particular column. With each new spreadsheet I
launch a new instance of excel. After about 100 spreadsheets, a "not
enough memory to start Excel" displays. When I checked the Task
Manager I had plenty of memory available--I was only using 10% of the
memory available.

I am setting my objects to nothing and tried using GC.Collect() but it
did not fix the problem.

Thank you for any help.
 
Elliot said:
The program loops through a dataset and creates several spreadsheets
based on a change in a particular column. With each new spreadsheet I
launch a new instance of excel. After about 100 spreadsheets, a "not
enough memory to start Excel" displays. When I checked the Task
Manager I had plenty of memory available--I was only using 10% of the
memory available.

Doctor, it hurts when I when I hit myself in the face. What should I do?

Um. Well, hmmm. Well don't do that.

Seriously, would you ever even consider launching 100 instances of excel
from the start menu? No that's just silly.

Not that it's a good idea, but you could open 100 workbooks in ONE instance
of Excel.

Dim ex As New Excel.ApplicationClass
Dim ws As New ArrayList
For i As Integer = 1 To 500
ws.Add(ex.Workbooks.Add())
Next

That instance of Excel required about 40mb of memory for all those
workbooks.

David
 
* (e-mail address removed) (Elliot) scripsit:
The program loops through a dataset and creates several spreadsheets
based on a change in a particular column. With each new spreadsheet I
launch a new instance of excel. After about 100 spreadsheets, a "not
enough memory to start Excel" displays. When I checked the Task
Manager I had plenty of memory available--I was only using 10% of the
memory available.

I am setting my objects to nothing and tried using GC.Collect() but it
did not fix the problem.

After calling Excel's 'Quit' method, you can use this code to release
the reference to the COM object:

\\\
System.Runtime.InteropServices.Marshal.ReleaseComObject(exApp)
///
 
I think this may be to do with GDI memory, not system memory. I would
suggest that you re-code it so as not to have 100 spreadsheets open at once,
why would you do this. ?

Try using ADO.NET to retreive the data you want to work on rather than
employing this method.

OHM
 
Back
Top