This project has moved and is read-only. For the latest updates, please go here.

Continued Memory Growth

Sep 6, 2012 at 5:50 PM
Edited Sep 6, 2012 at 7:48 PM

Hello, I am creating a spreadsheet in used within a web application.   Everything works great except it appears I am running out of memory.

With each use of library, I can see the memory continue to grow until memoryallocation errors start.

I believe the code is pretty straightforward.  I have tried calling the Dispose methods as well but that has no affect.

Am I doing something wrong or missing something?

Also, this is .Net 3.5   (might be the version I am using?????)

Using wb As New XLWorkbook()

            wb.EventTracking = XLEventTracking.Disabled



                'Create Response
                Dim resp = Response

                resp.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                resp.AddHeader("content-disposition", "attachment;filename=MyExcel.xlsx")
                resp.Charset = ""

                Using memoryStream As New MemoryStream()
                End Using


            Catch ex As Exception
                Label_Status_Msg.Text = "***** ERROR: Problem creating Excel Sheet *****" + ex.Message.ToString()
            End Try
        End Using

Sep 6, 2012 at 7:02 PM
Edited Sep 6, 2012 at 7:03 PM

There's nothing there that would keep the XL objects in memory. Did you do a memory profile to see what objects are held in memory?

btw, please edit your post to remove all the extra white space.

Sep 12, 2012 at 8:20 PM

Thanks for the response.   I did cleanup the white space.

I updated to the latest library version 6.7.2 for .Net 3.5

I am still having the memory issue.  It just grows and grows.....until boom  No more memory.

I don't have a profiler.  What would your recommend that is free?

Is there anything special I need to do that should clean this up?   I have everything in the using blocks

which should allow the garbage collection to take care of it.

The one thing I noticed is when the Excel sheet is opened, the title has multiple indexes in the name.



That seems to indicate that somewhere in memory are other versions of that worksheet.   My code

is in a web application so I'm not sure if the ISS server would hold onto it.


Thanks for the any help you may have.

Sep 12, 2012 at 8:39 PM

I still have my doubts about the problem being with this library. The following code runs indefinitely without increasing the memory usage:

            while (true)
                var wb = new XLWorkbook();
                wb.AddWorksheet(GetTable(), "Sheet1");
                using (var memoryStream = new MemoryStream())

As for a memory profiler, I use JetBrain's dotTrace Memory. They have a free trial if you want to test it.

Sep 13, 2012 at 2:30 PM

Thanks for the response.  I may know the issue.  Hopefully, you can let me know.

On my machine (testing), things seem to run fine.  The memory doesn't grow.   However, when

the job is put into production, wham we have major memory growth.

My machine is 64 bit.

The servers are 32 bit.  I just found out today.  I made a bad assumption.

Could this be the issue?   My hunch is yes.

If so, is there anything I can do about it or am I dead?

Thanks again.

Sep 13, 2012 at 3:38 PM

That one you're going to have to take to your IIS sysadmin...