Problem Description

Java runs out of memory while analyzing the code. The following error appears in the log files:

java.io.IOException: java.lang.OutOfMemoryError: Java heap space

 

Solution


First exclude all generated code.


The main source of problems when Teamscale runs out of memory is when the clone detection tries to find clones on large chunks of generated (often highly similar) code. Therefor the first solution should be to exclude any generated code in the project you are analyzing. 


For example, to exclude all code that lives in the folder gen-src, use the following exclude patterns on the Excluded File Names project setting: **/gen-src/**

The exclusion patterns are regular ant include patters


If excluding code by using directory structures does not work, you can use the advanced field Content Exclude. Use this to exclude files by their content, using regular expressions. For example to exclude all files that contain the documentation string "generated by Visual Studio", use: .*generated by Visual Studio.*




I've excluded all my generated code and Teamscale still runs out of memory.


If you have excluded all your generated source code and Teamscale still runs out of memory, you can adjust the amount of memory used by Teamscale.


On Windows:


Open teamscale.bat and change the line:

if not defined TEAMSCALE_MEMORY set TEAMSCALE_MEMORY=2500m


The 2500m defines the amount of memory used in megabytes. Try setting it to something higher, like 4000m or, if you want to go in gigabytes, 4G .


On Linux:


Open the file teamscale.sh and change the line:

 

  TEAMSCALE_MEMORY=2500m

 

The 2500m defines the amount of memory used in megabytes. Try setting it to something higher, like 4000m or, if you want to go in gigabytes, 4G .