Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"java.lang.OutOfMemoryError: Java heap space" error while running ScoverageXmlWriter #271

Open
sammy-1234 opened this issue Jul 17, 2019 · 0 comments

Comments

@sammy-1234
Copy link

sammy-1234 commented Jul 17, 2019

I get the "OutOfMemoryError" while generating scoverage xml reports for large projects (>50 targets/modules).

In my opinion, this is occurring because ScoverageXmlWriter.scala tries to first generate the entire XML tree in memory before writing it out to the file:

private def xml(coverage: Coverage): Node = {
<scoverage statement-count={coverage.statementCount.toString}
statements-invoked={coverage.invokedStatementCount.toString}
statement-rate={coverage.statementCoverageFormatted}
branch-rate={coverage.branchCoverageFormatted}
version="1.0"
timestamp={System.currentTimeMillis.toString}>
<packages>
{coverage.packages.map(pack)}
</packages>
</scoverage>
}

One way to resolve the issue would be to use a stream writer (e.g javax.xml.stream.XMLStreamWriter)to write the output. This would involve passing the writer as an argument to the xml(coverage: Coverage) function above. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants