Skip to content

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

Open
@sammy-1234

Description

@sammy-1234

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions