navkul Ответов: 2

Отчет Microsoft RDLC об исключении нехватки памяти в Asp.net


Я сгенерировал отчет rdlc примерно с 50 параметрами. Я экспортировал этот отчет в изображение динамически через localreport.рендер метод. Системы.outofmemory исключение возникает, когда отчет часто экспортируется. Пожалуйста, Помогите.

kiquenet.com

Моем случае о ***OutOfMemoryException*** не проблемы с памятью, я не знаю еще http://stackoverflow.com/questions/33436607/outofmemoryexception-using-rdlc-localreport-microsoft-reporting-webforms-in-as# _Maybe конфигурации служб IIS, бассейн, интернет.вопросы конфигурации ?_

2 Ответов

Рейтинг:
0

MetalKid007

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!


Рейтинг:
0

Sandeep Mewara

АФАИК, вы мало что можете с этим поделать(с точки зрения кода).
Обратитесь к следующей статье поддержки: MS Support: вы можете получить "System.Сообщение об ошибке OutOfMemoryException" при использовании служб SQL Server Reporting Services[^]

Посмотрите на эту дискуссию в том же духе: Экспорт в Excel выдает ошибку системы.OutOfMemoryException[^]

Попробуйте обновить свой веб - сервер-посмотрите на объем оперативной памяти, доступный на сервере, загрузку процессора при вызове отчета и объем дискового пространства сервера (для временного хранения).