您的位置:首页 > 其它

Getting System.OutOfMemoryException when using ReportViewer contol in Local mode

2010-02-04 16:52 1321 查看
PROBLEM:

========

Consider you've a ASP.NET application that contains Report Viewer control (2005 / 2008) in Local Mode.

You have an RDLC report file, that loads large amount of data / has lots of expressions. (Both are not recommended in Local mode)

Everytime you refresh the web page, the Report Viewer stores objects in the session.

The behaviour of Report Viewer storing objects in the session is by design.

Each time the report viewer page is refreshed the complete report info object is added to session.

These objects obviously gets deeply rooted in session and so Garbage collector never collects them untill the complete app unloads itself.

And that is apparently going to increase the memory pressure in multiple folds, ending up with System.OutOfMemoryException.

RESOLUTION: (Please note: This doesn't guarantee to resolve the exception. The Out of Memory exception can be caused due to different reasons and the below workaround is for one such scenario, which can help to avoid this error to a certain extent.)

===========

== In the page_load event, add this,

if(Session.Count > 0)

{

for (int i = 0; i < Session.Count; i++)

{

if (Session[i].GetType().ToString() == "Microsoft.Reporting.WebForms.ReportHierarchy")

{

Session.RemoveAt(i);

}

}

}

source: http://blogs.msdn.com/selvar/archive/2008/07/18/getting-system-outofmemoryexception-when-using-reportviewer-contol-in-local-mode.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐