VSTO 2010中的内存泄漏Excel文档级自定义 [英] Memory Leak in VSTO 2010 Excel document level customization

查看:129
本文介绍了VSTO 2010中的内存泄漏Excel文档级自定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我们在使用Excel 2010 - VSTO应用程序时出现内存泄漏问题。此自定义通过互操作与COM组件进行通信。


请注意,只要Excel.exe的内存使用量达到900 MB,就会出现"Assertion.Falied"。错误。


Excel 2003(VBA)中的类似应用程序使用COM组件,并在达到900 MB的阈值时崩溃。


但是与Excel 2003相比,Excel 2010的内存峰值更多(请注意,此自定义中嵌入了WPF控件),即Excel 2010与Excel 2003相比达到阈值的速度更快。


是有一个问题,或者就Excel 2010的内存消耗而言这是一种正常的行为。


请建议。


最好的问候

解决方案

嗨Arnav,


我没有遇到你所指的确切错误,但是我面对"OutOfMemoryException"好几次。我们开始使用

 Marshal.FinalReleaseComObject(dataRangeToBeValidated); 

来释放COM对象引用的语句,这确实减少了有点问题。在为数据透视表填充大数据时,我们仍然会遇到OOM异常,但它会间歇性地发生,并且当有许多其他应用程序或excels占用
内存时会发生。


还有一件事帮助我们减少初始内存消耗的是减少excel中的静态格式,并通过代码动态设置格式。


我希望这些信息可以帮到你。


阿维纳什。


Hi,

We have an issue with the memory leak with Excel 2010 - VSTO application. This customization talks to COM components through interops.

Please note than whenever the memory usage of the Excel.exe reaches 900 MB there is an "Assertion.Falied" error.

Similar application in Excel 2003 (VBA) uses COM component and also crashes when the threshold value of 900 MB is reached.

But the spike in memory for Excel 2010 is more (note that this customization has WPF controls embedded in it) compared to Excel 2003, i.e. Excel 2010 reaches the threshold value faster compared to Excel 2003.

Is there a problem or is this a normal behavior as far as memory consumption of Excel 2010 is concerned.

Please suggest.

Best Regards

解决方案

Hi Arnav,

I haven't encountered the exact error you are referring to, however I have faced "OutOfMemoryException" quite a few times. We started using

Marshal.FinalReleaseComObject(dataRangeToBeValidated);

to statement to release COM object references, that did reduce the issue somewhat. We still face the OOM exception when populating large data for a pivot but it happens intermitently and happens when there are number of other applications or excels hogging the memory.

One more thing that helped us reduce the initial memory consumption was to reduce static formatting in the excel and set format dynamically through code.

I hope this information helps you somewhat.

Avinash.


这篇关于VSTO 2010中的内存泄漏Excel文档级自定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆