Asp.net中的Microsoft RDLC报告内存异常 [英] Microsoft RDLC Report Out of Memory Exception in Asp.net

查看:115
本文介绍了Asp.net中的Microsoft RDLC报告内存异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经生成了一个包含大约50个参数的rdlc报告。我已通过 localreport.render 方法动态导出此报告。频繁导出报表时发生 System.outofmemory 异常。 Plz帮助。

I have generated an rdlc report with about 50 parameters. I have exported this report to image dynamically through localreport.render method. System.outofmemory exception occurs when the report is frequently exported. Plz Help.

推荐答案

AFAIK,你可以做的很少(代码方面)。

参考以下支持文章: MS支持:使用SQL Server Reporting Services时可能会收到System.OutOfMemoryException错误消息 [ ^ ]



请看类似行的讨论:导出到Excel错误抛出System.OutOfMemoryException [ ^ ]



尝试升级您的Web服务器 - 查看服务器上可用的RAM,处理器调用报告时的利用率,以及服务器磁盘空间量(用于临时存储)。
AFAIK, there is not much(code wise) that you can do about it.
Refer the following support article: MS Support: You may receive the "System.OutOfMemoryException" error message when you use SQL Server Reporting Services[^]

Look at this discussion on similar lines: Export To Excel Error throws System.OutOfMemoryException[^]

Try to upgrade your web server - look at the RAM available on the server, the processor utilization when the report is called, and the amount of server disk space (for temp storage).


I'm pretty late to this, but I have a real solution and can explain why!

It turns out that LocalReport here is using .NET Remoting to dynamically create a sub appdomain and run the report in order to avoid a leak internally somewhere. We then notice that, eventually, the report will release all the memory after 10 to 20 minutes. For people with a lot of PDFs being generated, this isn't going to work. However, the key here is that they are using .NET Remoting. One of the key parts to Remoting is something called "Leasing". Leasing means that it will keep that Marshal Object around for a while since Remoting is usually expensive to setup and its probably going to be used more than once. LocalReport RDLC is abusing this.

By default, the leasing time is... 10 minutes! Also, if something makes various calls into it, it adds another 2 minutes to the wait time! Thus, it can randomly be between 10 and 20 minutes depending how the calls line up. Luckily, you can change how long this timeout happens. Unluckily, you can only set this once per app domain... Thus, if you need remoting other than PDF generation, you will probably need to make another service running it so you can change the defaults. To do this, all you need to do is run these 4 lines of code at startup:

    LifetimeServices.LeaseTime = TimeSpan.FromSeconds(5);
    LifetimeServices.LeaseManagerPollTime = TimeSpan.FromSeconds(5);
    LifetimeServices.RenewOnCallTime = TimeSpan.FromSeconds(1);
    LifetimeServices.SponsorshipTimeout = TimeSpan.FromSeconds(5);

You'll see the memory use start to rise and then within a few seconds you should see the memory start coming back down. Took me days with a memory profiler to really track this down and realize what was happening.

You can't wrap ReportViewer in a using statement (Dispose crashes), but you should be able to if you use LocalReport directly. After that disposes, you can call GC.Collect() if you want to be doubly sure you are doing everything you can to free up that memory.

Hope this helps!


这篇关于Asp.net中的Microsoft RDLC报告内存异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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