1

I wrote a small .NET add in to excel 2007 that read data from external c++ api and display it inside an excel.
The task manager shows that I'm having a memory leak (the memory usage is inflate linearly up to 250MB after whitch it throws an "Excel cannot complete this task with available resources error") but the problem disappears as soon as I minimize the excel window.

The api uses delegates to return data and I update it into a dictionary. another thread is updating the excel from the dictionary every second.

It is unlikely that the unmanaged code is responsible of the leak.

Does anybody have an idea what can cause this?

10x!

tsinik
  • 503
  • 5
  • 11
  • How do you reason that the memory usage is due a memory leak? If there was a like why would it stop at 250 MB? And minimizing a window does not fix leaks. – Dirk Vollmar May 03 '10 at 14:33
  • I stop after 250MB becuse the excel is giving me a "cannot complete the operation with the available resources". – tsinik May 03 '10 at 14:37
  • 1
    Are you on XP? Task manager only shows you the working set which gets reduced by the OS when minimizing the application's main window. I'd suggest to use Process Explorer to see the private bytes. See also http://channel9.msdn.com/forums/TechOff/454007-Minimize-Window-Drop-its-Mem-Usage/ – Dirk Vollmar May 03 '10 at 14:44
  • It is XP. I know that the task manager is not to be trusted but the messege from the excel dosen't look good on a production – tsinik May 03 '10 at 14:46
  • Can you try to track down the line of code that triggers the error? The error message you are getting might be due to missing patches or limitations of Excel (see http://support.microsoft.com/kb/292471/en-us and http://support.microsoft.com/kb/331863/en-us). – Dirk Vollmar May 03 '10 at 14:52
  • It's not in any single line of code, the problem is the huge memory consumption. – tsinik May 03 '10 at 14:59
  • 250MB is far below the per-process limit of 2GB. The message is certainly triggered by a call into Excel's object model. Can you try to debug which call it is and whether it is the same call all the time? – Dirk Vollmar May 03 '10 at 15:03

1 Answers1

0

I've found the problem. I was updating the cells by setting the Formula property whitch is taking more time. The excel didn't managed to complite all the updates on time and the stack grow. After I changed the way I update the cells to set_value it became OK.

Thanks to all.

tsinik
  • 503
  • 5
  • 11