In a previous Blog dated back year 2014
I have tried to give an overview related to the Out Of Memory exception that you might hit with Microsoft Dynamics NAV RDLC Report with the following versions: 2009 R2, 2013 and 2013 R2.
The main focus of my dissertation now is based on the improvement made with Microsoft Dynamics NAV 2015 and 2016 related to report performance. I would encourage you to post your comments and thoughts, as usual. Have a good read.
NAV 2015 (RDLC 2010 – Report Viewer 2014)
The same optimization tips posted in the previous blog are still valid. With Microsoft Dynamics NAV 2015 it has been introduced out-of-the-box a powerful feature to automatic schedule reports to be printed server side through a Job Queue. You could take as reference the MSDN entry below
And the following video
Please, be sure to have enough memory server side to cope with the Schedule a Report feature.
With Microsoft Dynamics NAV 2015 and considering so-called heavy reports, I would then strongly recommend you to enable and take advantage of this feature. The same principle applies if you have to print a discrete amount of reports (typically from hundreds to thousands) in a short time frame.
NAV 2016 (RDLC 2010 – Report Viewer 2015)
With this latest version, the Microsoft Dynamics NAV Windows client is available in a 32-bit version and 64-bit version. The 32-bit version of the Microsoft Dynamics NAV Windows client can be run on either a 32-bit or 64-bit version of a Windows operating system. The 64-bit version of the Microsoft Dynamics NAV Windows client can only be run on a 64-bit version of a Windows operating system. On a 64-bit Windows operating system, the 64-bit version of the Microsoft Dynamics NAV Windows client is used by default.
If you are using the 64-bit Microsoft Dynamics NAV Windows Client this now enables the usage of more memory for report dataset therefore the Out Of Memory bar is raised higher compared to all other versions. Even if the Microsoft Dynamics NAV 2016 64-bit Windows Client might allow you to preview / print a more consistent dataset compared to all previous versions that do support RDLC reports, it is always recommended for long batch printing (heavy reports) to enable the schedule a report feature in order to have a more robust server side printing in background.
Important considerations using Server Side Printing
Microsoft Dynamics NAV RDLC Report memory usage and performance are tightly related.
Considering the same dataset dimension, memory footprint and performance are influenced by:
- VB.NET SHARED VARIABLES Within Microsoft Dynamics NAV Report context, these are typically used for SETDATA and GETDATA trick. E.g. in Microsoft Dynamics NAV 2016 standard Cronus W1 Report 206 you could find these shared variables in the RDLC Report Code section
Shared Data1 as Object
Shared Data2 as Object
Shared Data3 as Object
Shared Data4 as Object
Even if several (many) standard reports are using VB.NET Shared Variables, this is basically discouraged within RDLC reports since the Report Viewer cannot reuse the expressionhost and therefore creates a new one each time the report is run. The recycle of these objects is pretty crucial in some scenarios and is tightly depending on legacy Code Access Security (CAS) policy switch.
- CODE ACCESS SECURITY (CAS) POLICY SWITCH. The default value for Microsoft Dynamics NAV 2015 e NAV 2016 is true (CAS Policy enabled). CAS policy is defined server side by the NetFx40_LegacySecurityPolicy parameter that you will find in the Microsoft.Dynamics.NAV.Server.exe.config XML file in the NAV Server folder.
Stated the above, to demonstrate the behavior and results, I am using a simple codeunit to be run server side through Job Queue.
FOR i := 1 TO 16000 DO BEGIN
LOCAL SaveReportAsPdf(loopNo : Integer)
report.USEREQUESTPAGE := FALSE;
report.SAVEASPDF(‘C:/Temp/PDF/’ + FORMAT(loopNo) + ‘report-to-delete.pdf’);
With Local variables for function SaveReportAsPdf
Name DataType Subtype Length
report Report Sales – Invoice
rec Record Sales Invoice Header
(NOTE: report variable could be either Report ID 206 or Report ID 1306, depending on the test performed below.)
This codeunit is generating 16.000 PDF document server side and for the sake of the test I run this 4 time using report 206 (that contains VB.Net shared variables) and report 1306 (does not contain any VB.Net shared variable), with or without CAS policy enabled.
See below results of the test
|NETFX40 SWITCH||Shared Variables||No. doc||MEM (GB)||Time (min)|
- CAS policy enabled and with VB.Net shared variables (Report 206)
Memory behavior: slowly but constant consumption increase without appropriate recycling. This scenario cause memory leak. Faster execution than with CAS Policy disabled (152 mins for 16000 documents). This is the typical NAV default Scenario.
- CAS policy disabled and with VB.Net shared variables (Report 206)
Memory behavior: initially increase consumption very fast until it starts recycling. With the appropriate memory size, it does not cause memory leak. This scenario has the slowest execution (193 mins for 16000 documents).
- CAS policy enabled and without VB.Net shared variables (Report 1306)
Memory behavior: very low and stable consumption around 200 MB. Memory is completely released for every document printed. It does not cause memory leak. This is the best scenario both in terms of memory footprint and performance: it takes up to 20 mins to generate 16000 PDF documents.
- CAS policy disabled and without VB.Net shared variables (Report 1306)
Memory behavior: initially increase consumption very fast until it starts recycling. With the appropriate memory size, it does not cause memory leak. Really very slow performance compared to the same scenario with CAS Policy enabled
Takeaways from this practical test could be resumed as per the following:
- Avoid using VB.Net shared variables as much as possible within RDLC Reports
- If you cannot make it to get rid of these and your requirement is to generate a high volume of reports in short time, it is recommended to deploy a dedicated NAV Server service with CAS policy disabled in order to avoid memory leak, even if this might result in a slower execution.
These postings are provided “AS IS” with no warranties and confer no rights. You assume all risk for your use.
Duilio Tacconi (dtacconi)
Microsoft Dynamics Italy
Microsoft Customer Service and Support (CSS) EMEA
A special thanks to Christian Clausen / Telebilling