+ Reply to Thread
Results 1 to 3 of 3

Excel.EXE remains in memory

Hybrid View

  1. #1
    harshu4u@gmail.com
    Guest

    Excel.EXE remains in memory

    Hello All,

    We are generating excel sheets using COM Interop. When the sheet
    generation is successful, it removes the EXCEL.EXE from the task
    manager. However, if we have any error in the application, the
    EXCEL.EXE remains in memory (can see it in task manager). What are we
    doing wrong? Any inupt will be highly appreciated.

    Here's the cleanup code:

    finally
    {
    if (module != null)
    Marshal.ReleaseComObject(module);
    if (range != null)
    Marshal.ReleaseComObject(range);
    if (color != null)
    Marshal.ReleaseComObject(color);
    if (sheet1 != null)
    Marshal.ReleaseComObject(sheet1);
    if (sheet2 != null)
    Marshal.ReleaseComObject(sheet2);
    if (sheet3 != null)
    Marshal.ReleaseComObject(sheet3);
    if (workbook != null)
    Marshal.ReleaseComObject
    (workbook);
    if (excelApp != null)
    Marshal.ReleaseComObject(excelApp);

    module = null;
    range = null;
    color = null;
    sheet1 = null;
    sheet2 = null;
    sheet3 = null;
    workbook = null;
    excelApp = null;
    }


    Thanks,
    Harshu


  2. #2
    Andrew Taylor
    Guest

    Re: Excel.EXE remains in memory

    Try adding the lines

    workbook.close
    excelApp.Quit

    before destroying the objects.





    harshu4u@gmail.com wrote:
    > Hello All,
    >
    > We are generating excel sheets using COM Interop. When the sheet
    > generation is successful, it removes the EXCEL.EXE from the task
    > manager. However, if we have any error in the application, the
    > EXCEL.EXE remains in memory (can see it in task manager). What are we
    > doing wrong? Any inupt will be highly appreciated.
    >
    > Here's the cleanup code:
    >
    > finally
    > {
    > if (module != null)
    > Marshal.ReleaseComObject(module);
    > if (range != null)
    > Marshal.ReleaseComObject(range);
    > if (color != null)
    > Marshal.ReleaseComObject(color);
    > if (sheet1 != null)
    > Marshal.ReleaseComObject(sheet1);
    > if (sheet2 != null)
    > Marshal.ReleaseComObject(sheet2);
    > if (sheet3 != null)
    > Marshal.ReleaseComObject(sheet3);
    > if (workbook != null)
    > Marshal.ReleaseComObject
    > (workbook);
    > if (excelApp != null)
    > Marshal.ReleaseComObject(excelApp);
    >
    > module = null;
    > range = null;
    > color = null;
    > sheet1 = null;
    > sheet2 = null;
    > sheet3 = null;
    > workbook = null;
    > excelApp = null;
    > }
    >
    >
    > Thanks,
    > Harshu



  3. #3
    Pflugs
    Guest

    Re: Excel.EXE remains in memory

    I have this same problem, and I am using ActiveWorkbook.close and
    Excel.Application.Quit before destroying the objects. I still have Excel.exe
    in memory. Is there anything else I can do?

    Thanks.

    Pflugs

    "Andrew Taylor" wrote:

    > Try adding the lines
    >
    > workbook.close
    > excelApp.Quit
    >
    > before destroying the objects.
    >
    >
    >
    >
    >
    > harshu4u@gmail.com wrote:
    > > Hello All,
    > >
    > > We are generating excel sheets using COM Interop. When the sheet
    > > generation is successful, it removes the EXCEL.EXE from the task
    > > manager. However, if we have any error in the application, the
    > > EXCEL.EXE remains in memory (can see it in task manager). What are we
    > > doing wrong? Any inupt will be highly appreciated.
    > >
    > > Here's the cleanup code:
    > >
    > > finally
    > > {
    > > if (module != null)
    > > Marshal.ReleaseComObject(module);
    > > if (range != null)
    > > Marshal.ReleaseComObject(range);
    > > if (color != null)
    > > Marshal.ReleaseComObject(color);
    > > if (sheet1 != null)
    > > Marshal.ReleaseComObject(sheet1);
    > > if (sheet2 != null)
    > > Marshal.ReleaseComObject(sheet2);
    > > if (sheet3 != null)
    > > Marshal.ReleaseComObject(sheet3);
    > > if (workbook != null)
    > > Marshal.ReleaseComObject
    > > (workbook);
    > > if (excelApp != null)
    > > Marshal.ReleaseComObject(excelApp);
    > >
    > > module = null;
    > > range = null;
    > > color = null;
    > > sheet1 = null;
    > > sheet2 = null;
    > > sheet3 = null;
    > > workbook = null;
    > > excelApp = null;
    > > }
    > >
    > >
    > > Thanks,
    > > Harshu

    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1