MATLAB: How to increase the available memory for Polyspace Report Generator with PDF output format

generationoutofmemoryerrorpolyspacePolyspace Bug FinderPolyspace Bug Finder ServerPolyspace Code ProverPolyspace Code Prover Serverreport

When I try to generate a Polyspace Report (Reporting > Run Report) with output format PDF, I get below Java OutOfMemoryError in the report generation log.
How do I increase the available memory for Polyspace Report Generator with PDF output format?
Report Generation Call: C:\work\matlab\2015b\polyspace\bin\polyspace-report-generator.exe -template C:\work\matlab\2015b\polyspace\toolbox\psrptgen\templates\CodeMetrics.rpt -results-dir "<output_path>\_results" -format PDF
Polyspace Report Generator
Generating Report
Template : C:\work\matlab\2015b\polyspace\toolbox\psrptgen\templates\CodeMetrics.rpt
Results-dir : <dir_results>
Format : pdf
Output-Name : <output_path>\Polyspace-Doc\<prj_name>_CodeMetrics.pdf
Beginning report
Processing Metrics Summary
Processing Metrics Details
Processing Configuration
Converting report
Document conversion failed. Java exception occurred: java.lang.OutOfMemoryError: Java heap space at org.apache.fop.layoutmgr.inline.LineLayoutManager.addInlineArea(Unknown Source) at org.apache.fop.layoutmgr.inline.LineLayoutManager.addAreas(Unknown Source) at
[...]
Error using xslt (line 95)
Java exception occurred:
java.lang.OutOfMemoryError: Java heap space
at org.apache.fop.layoutmgr.inline.LineLayoutManager.addInlineArea(Unknown Source)
at org.apache.fop.layoutmgr.inline.LineLayoutManager.addAreas(Unknown Source)
[...]
Error in rpt_xml.db_output/convertReport>locRunXsltEngine (line 286)
Error in rpt_xml.db_output/convertReport (line 21)
Error in rptgen.coutline/makeDocumentPost (line 40)
Error in rptgen.coutline/execute (line 21)
Error in polyspace_report (line 211)

Best Answer

In order to increase the Java memory for Polyspace, please navigate to the folder
<matlabroot>/polyspace/bin/win64 (for 64-bit installations)
<matlabroot>/polyspace/bin/win32 (for 32-bit installations)
and change the java.opts file in a text editor. By default, its content is -Xmx1024m, so you can change the Java memory for example to 2048 MB by entering -Xmx2048m.
Note that <matlabroot> is your MATLAB installation folder, which you can obtain by entering
>>matlabroot
at the MATLAB Command Prompt.
Polyspace R2013a and earlier:
In earlier versions of Polyspace, java.opts can be found in:
C:\PolySpace\PolySpace_Common\ReportGenerator\bin\x86_64-mingw32
and/or
C:\PolySpace\PolySpace_Common\ReportGenerator\bin\x86-mingw32
Please note that the x86_64 folder is for the 64bit binary and the other is for the 32bit binary, you only need to change one, but you need to figure out which is the one you are using. But it is also fine if you just change both of them.
Please also note that the directory here is an example Polyspace installation directory, you might need to adapt in your case.